예제 #1
0
 def post(self):
     data = parserU.parse_args()
     current_user = Users.find_by_username(data['username'])
     if not current_user:
         return {
             'message': 'User {} doesn\'t exist'.format(data['username'])
         }, 400
     if Users.verify_hash(data['password'], current_user.password):
         access_token = create_access_token(identity=data['username'])
         refresh_token = create_refresh_token(identity=data['username'])
         return {
             'message': 'Logged in as {}'.format(current_user.username),
             'access_token': access_token,
             'refresh_token': refresh_token
         }, 200
     else:
         return {'message': 'Wrong credentials'}, 400