当前位置: 首页>>代码示例>>Python>>正文


Python User.verify_auth_token方法代码示例

本文整理汇总了Python中app.users.models.User.verify_auth_token方法的典型用法代码示例。如果您正苦于以下问题:Python User.verify_auth_token方法的具体用法?Python User.verify_auth_token怎么用?Python User.verify_auth_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.users.models.User的用法示例。


在下文中一共展示了User.verify_auth_token方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CreateComment

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import verify_auth_token [as 别名]
def CreateComment():
    if request.method=='GET':
        return json.dumps({'message':'Please use method POST!'})
    if request.method=='POST':
        token=request.values.get('token')
        if token is None:
            return json.dumps({'message':'Need Token!'})
        user=User.verify_auth_token(token)
        if type(user) is types.StringType:
            return json.dumps({'message':user})
        if request.values.get('DishID') is None:
            return json.dumps({'message':'Need DishID!'})
        if YMDish.query.filter(YMDish.DishID==request.values.get('DishID')).all() is None:
            return json.dumps({'message':'DishID is invalid!'})
        if request.values.get('Content') is None:
            return json.dumps({'message':'Need Content!'})

        else:
            ym_dish_comments=YMDishComment(UserName=user.UserName,DishID=request.values.get('DishID')
                                           ,Time=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
                                           ,Content=request.values.get('Content'))
            try:
                ym_dish_comments.save()
            except:
                return json.dumps({'message':'Comment Existed!'})
            return json.dumps({'message':'Add Comment Success!'})
开发者ID:fishersosoo,项目名称:YM,代码行数:28,代码来源:views.py

示例2: GetLikeDish

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import verify_auth_token [as 别名]
def GetLikeDish():
    if request.method=='GET':
        return json.dumps({'message':'Please use method POST!'})
    if request.method=='POST':
        token=request.values.get('token')
        if token is None:
            return json.dumps({'message':'Need Token!'})
        user=User.verify_auth_token(token)
        if type(user) is types.StringType:
            return json.dumps({'message':user})
        like_diskes=db.session.query(YMDish).join(LikeDish).filter(LikeDish.UserName==user.UserName).all()
        List=[]
        for one in like_diskes:
            List.append({'DishID':one.DishID
             ,'DishType':one.DishType
             ,'DishSmallImage':one.DishSmallImage
             ,'DishLargeImage':one.DishLargeImage
             ,'DishName':one.DishName
             ,'Taste':one.Taste
             ,'RawStuff':one.RawStuff
             ,'Locations':one.Locations
             ,'Description':one.Description
             ,'Price':str(one.Price)
             ,'Like':one.Like
             ,'Favorite':one.Favorite})
        return json.dumps({'Dish_List':json.dumps(List)})
开发者ID:fishersosoo,项目名称:YM,代码行数:28,代码来源:views.py

示例3: verify_password

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import verify_auth_token [as 别名]
def verify_password(email_or_token, password):
    # first try to authenticate by token
    user = User.verify_auth_token(email_or_token)
    if not user:
        # try to authenticate with username/password
        user = User.query.filter_by(email=email_or_token).first()
        if not user or not user.verify_password(password):
            return False
    g.user = user
    return True
开发者ID:vsilent,项目名称:Vision,代码行数:12,代码来源:api.py

示例4: Like

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import verify_auth_token [as 别名]
def Like():
    if request.method=='GET':
        return json.dumps({'message':'Please use method POST!'})
    if request.method=='POST':
        token=request.values.get('token')
        if token is None:
            return json.dumps({'message':'Need Token!'})
        user=User.verify_auth_token(token)
        if type(user) is types.StringType:
            return json.dumps({'message':user})
        if request.values.get('DishID') is None:
            return json.dumps({'message':'Need DishID!'})
        like_dish=LikeDish(DishID=request.values.get('DishID'),UserName=user.UserName)
        try:
            like_dish.save()
        except :
            return json.dumps({'message':'Already like!'})
        dish=YMDish.query.filter(YMDish.DishID==request.values.get('DishID')).first()
        dish.Like=dish.Like+1
        dish.save()
        return json.dumps({'message':'Like Success!'})
开发者ID:fishersosoo,项目名称:YM,代码行数:23,代码来源:views.py

示例5: Favorite

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import verify_auth_token [as 别名]
def Favorite():
    if request.method == 'GET':
        return json.dumps({'message': 'Please use method POST!'})
    if request.method == 'POST':
        token = request.values.get('token')
        if token is None:
            return json.dumps({'message': 'Need Token!'})
        user = User.verify_auth_token(token)
        if type(user) is types.StringType:
            return json.dumps({'message': user})
        if request.values.get('DishID') is None:
            return json.dumps({'message': 'Need DishID!'})
        favorite_dish = FavoriteDish(DishID=request.values.get('DishID'), UserName=user.UserName)
        try:
            favorite_dish.save()
        except:
            return json.dumps({'message': 'Already Favorite!'})
        dish = YMDish.query.filter(request.values.get('DishID') == YMDish.DishID).first()
        dish.Favorite += 1
        dish.save()
        return json.dumps({'message': 'Favorite Success!'})
开发者ID:fishersosoo,项目名称:YM,代码行数:23,代码来源:views.py

示例6: DontLike

# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import verify_auth_token [as 别名]
def DontLike():
    if request.method=='GET':
        return json.dumps({'message':'Please use method POST!'})
    if request.method=='POST':
        token=request.values.get('token')
        if token is None:
            return json.dumps({'message':'Need Token!'})
        user=User.verify_auth_token(token)
        if type(user) is types.StringType:
            return json.dumps({'message':user})
        if request.values.get('DishID') is None:
            return json.dumps({'message':'Need DishID!'})
        like_dish=LikeDish.query.filter(LikeDish.DishID==request.values.get('DishID')
                                        ,LikeDish.UserName==user.UserName).first()
        if like_dish is None:
            return json.dumps({'message':'Not Like!'})
        db.session.delete(like_dish)
        db.session.commit()
        dish=YMDish.query.filter(YMDish.DishID==request.values.get('DishID')).first()
        dish.Like=dish.Like-1
        dish.save()
        return json.dumps({'message':'Dont Like Success!'})
开发者ID:fishersosoo,项目名称:YM,代码行数:24,代码来源:views.py


注:本文中的app.users.models.User.verify_auth_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。