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