Rapportsystem API - of D03N
Hovedprosjekt FiV Programmering 20-24
Loading...
Searching...
No Matches
admin_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 admin
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 admin
12 current_user = get_jwt_identity()
13 if current_user['accountType'] != 'admin':
14 return {"Error": "You need an Admin account for this."}, 403
15 return func(*args, **kwargs)
16 return wrapped
require_admin_account(func)
Definition admin_req.py:6