def post(self):
"""Login the user"""
username = request.json['username']
password = request.json['password']
us = User.query\
.filter(User.disabled is False)\
.filter(User.sigaa_user_name == username)\
.first()
abort_if_none(us, 403, 'Username or password incorrect')
if not check_password_hash(us.password, password):
return msg('Username or password incorrect'), 403
token = jwt.encode(
{'id_user': us.id_user, 'tid': random.random()},
config.SECRET_KEY,
algorithm='HS256'
).decode('utf-8')
return msg(token, 'token')
评论列表
文章目录