Commit cdb9a728 authored by Willard's avatar Willard

Add error handler for API auth

parent d7ca7c3b
......@@ -95,6 +95,14 @@ def get_auth_token():
token = generate_token(g.user)
return jsonify({'token': token.decode('ascii'), 'duration': 600})
@auth.error_handler
def unauthorized():
return jsonify({
'status': 401,
'error': 'unauthorized',
'message': 'Invalid login credentials!'
})
@app.route('/api/dishes/<int:dish_id>/favorites', methods=['GET', 'POST'])
@auth.login_required
def dish_favorite(dish_id):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment