From 2478e35f8dd353643c94aa8d8cc7ec70036a74ab Mon Sep 17 00:00:00 2001 From: Corban-Lee Date: Wed, 26 Jun 2024 11:06:29 +0100 Subject: [PATCH] super user environment variables over hardcode --- apps/authentication/backends.py | 5 +++-- core/settings.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/authentication/backends.py b/apps/authentication/backends.py index ddb1359..75c45d4 100644 --- a/apps/authentication/backends.py +++ b/apps/authentication/backends.py @@ -2,6 +2,7 @@ import logging +from django.conf import settings from django.http import HttpResponse from django.contrib.auth.backends import BaseBackend @@ -56,8 +57,8 @@ class DiscordAuthenticationBackend(BaseBackend): existing_user.save() return existing_user - # hardcode admin for myself - if discord_user_id == "377453890523627522": + # Provide superuser permissions for specified users + if discord_user_id in settings.SUPERUSER_IDS: return DiscordUser.objects.create_superuser(discord_user_data) return DiscordUser.objects.create_user(discord_user_data) diff --git a/core/settings.py b/core/settings.py index d7dd3c3..5c68a5e 100644 --- a/core/settings.py +++ b/core/settings.py @@ -150,6 +150,7 @@ DISCORD_REFRESH_TOKEN_REQUEST = { } DISCORD_API_URL = env("DISCORD_API_URL") DISCORD_OAUTH2_URL = env("DISCORD_OAUTH2_URL") +SUPERUSER_IDS = env("SUPERUSER_IDS").split(",") # Logging # https://docs.djangoproject.com/en/5.0/topics/logging/