#29-add-admin-role #2
2 changed files with 5 additions and 5 deletions
|
@ -14,7 +14,7 @@ from .lit_user_service import UserService
|
||||||
@api_v1.route("/users", methods=["GET"])
|
@api_v1.route("/users", methods=["GET"])
|
||||||
@jwt_required()
|
@jwt_required()
|
||||||
@cross_origin()
|
@cross_origin()
|
||||||
@admin_required()
|
# @admin_required() TODO: not needed as authentik checks permissions?
|
||||||
def get_users():
|
def get_users():
|
||||||
return jsonify(UserService.get_users())
|
return jsonify(UserService.get_users())
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ def admin_required():
|
||||||
@wraps(fn)
|
@wraps(fn)
|
||||||
def decorator(*args, **kwargs):
|
def decorator(*args, **kwargs):
|
||||||
verify_jwt_in_request()
|
verify_jwt_in_request()
|
||||||
# claims = get_jwt()
|
claims = get_jwt()
|
||||||
# user_id = claims["user_id"]
|
|
||||||
is_admin = True # RoleService.is_user_admin(user_id)
|
user_id = claims["user_id"]
|
||||||
# TODO: actually check if admin
|
is_admin = RoleService.is_user_admin(user_id)
|
||||||
if is_admin:
|
if is_admin:
|
||||||
return fn(*args, **kwargs)
|
return fn(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue