Define superusers

This commit is contained in:
Yohann D'ANELLO 2020-11-16 04:06:46 +01:00
parent fc18f93ff8
commit c02380a1e4
3 changed files with 10 additions and 1 deletions

View File

@ -70,6 +70,7 @@ class OAuthMiddleware(MiddlewareMixin):
user.discriminator = user_json['discriminator']
user.email = user_json['email']
user.avatar_id = user_json['avatar']
user.is_superuser = f"{user.username}#{user.discriminator}" in settings.SUPERUSERS
user.save()
request.session['user'] = user.discord_id
return user

6
lglog/secrets_example.py Normal file
View File

@ -0,0 +1,6 @@
OAUTH_CLIENT_ID = 'CHANGE_ME'
OAUTH_CLIENT_SECRET = 'CHANGE_ME'
SUPERUSERS = [
'ÿnérant#0719',
]

View File

@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from pathlib import Path
from .secrets import OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET
from .secrets import OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, SUPERUSERS
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -162,3 +162,5 @@ OAUTH_CLIENT = {
},
'userinfo_endpoint': 'users/@me',
}
SUPERUSERS = SUPERUSERS