Commit f1fc7a62 authored by sim's avatar sim

[JWT] Map database access control to django auth system

parent 0ef8069e
......@@ -126,7 +126,8 @@ JWT_AUTH = {
'JWT_AUTH_HEADER_PREFIX': 'Bearer',
}
ROLE_ADMIN = 'gargantua'
ROLE_SUPERUSER = 'gargantua'
ROLE_STAFF = 'gargandmin'
ROLE_USER = 'gargantext'
# Static files (CSS, JavaScript, Images)
......
......@@ -7,9 +7,10 @@ from .dates import datetime
def jwt_payload_handler(user):
username = user.username
payload = {
'user_id': user.pk,
'role': settings.ROLE_ADMIN if username == settings.ROLE_ADMIN else \
'role': settings.ROLE_SUPERUSER if user.is_superuser else \
settings.ROLE_STAFF if user.is_staff else \
settings.ROLE_USER,
'user_id': user.pk,
'username': username,
'exp': datetime.now() + api_settings.JWT_EXPIRATION_DELTA
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment