當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。