Skip to content

Commit 1e90059

Browse files
committed
User context annotation added
1 parent efe58d9 commit 1e90059

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

activities/context.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from flask import request, abort
2+
from functools import wraps
3+
4+
5+
def user_context(function):
6+
@wraps(function)
7+
def decorated_function(*args, **kwargs):
8+
user_id = request.headers.get('X-Foodlove-User-Id', None)
9+
10+
if user_id is not None:
11+
return function(user_id=int(user_id), *args, **kwargs)
12+
else:
13+
abort(401)
14+
return decorated_function

0 commit comments

Comments
 (0)