def post(self): data = parser.parse_args() current_user = UserModel.find_by_username(data['username']) if not current_user: return { 'message': 'User {} doesn\'t exist'.format(data['username']) } if UserModel.verify_hash(data['password'], current_user['password']): access_token = create_access_token( identity=current_user.doc_id, expires_delta=datetime.timedelta(hours=1)) return { 'message': 'Logged in as {}'.format(current_user["username"]), 'access_token': access_token, } else: return {'message': 'Wrong credentials'}