本文整理汇总了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!'})
示例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)})
示例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
示例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!'})
示例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!'})
示例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!'})