Rapportsystem API - of D03N
Hovedprosjekt FiV Programmering 20-24
Loading...
Searching...
No Matches
leader_req.py
Go to the documentation of this file.
1#Importing the required modules
2from flask_jwt_extended import jwt_required, get_jwt_identity
3from functools import wraps
4
5#Function that checks if the user is an leader
7 @wraps(func)
8 #requires a token
9 @jwt_required()
10 def wrapped(*args, **kwargs):
11 #gets the current user and checks if the account type is leader
12 current_user = get_jwt_identity()
13 if current_user['accountType'] != 'leader':
14 return {"Error": "You need an leader account for this."}, 403
15 return func(*args, **kwargs)
16 return wrapped
require_leader_account(func)
Definition leader_req.py:6