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
2
from
flask_jwt_extended
import
jwt_required, get_jwt_identity
3
from
functools
import
wraps
4
5
#Function that checks if the user is an operator
6
def
require_operator_account
(func):
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
operator_req.require_operator_account
require_operator_account(func)
Definition
operator_req.py:6
rapportsystem-backend
Common
Requirements
operator_req.py
Generated by
1.10.0