We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6801924 commit 18b0c22Copy full SHA for 18b0c22
ennead/utils.py
@@ -3,7 +3,7 @@
3
from typing import Any, Callable
4
from functools import wraps
5
6
-from flask import g, redirect, url_for
+from flask import g, abort, redirect, url_for
7
from werkzeug.wrappers import Response
8
9
@@ -29,3 +29,16 @@ def wrapped(*args: Any, **kwargs: Any) -> Response:
29
return func(*args, **kwargs)
30
31
return wrapped
32
+
33
34
+def require_teacher(func: Callable) -> Callable:
35
+ """Make endpoint require logged in teacher"""
36
37
+ # pylint: disable=inconsistent-return-statements
38
+ @wraps(func)
39
+ def wrapped(*args: Any, **kwargs: Any) -> Response:
40
+ if g.user and g.user.is_teacher:
41
+ return func(*args, **kwargs)
42
+ abort(403)
43
44
+ return wrapped
0 commit comments