feat(settings/base.py): support GitHub OAuth
This commit is contained in:
@@ -10,13 +10,19 @@ For the full list of settings and their values, see
|
|||||||
https://docs.djangoproject.com/en/6.0/ref/settings/
|
https://docs.djangoproject.com/en/6.0/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import dotenv
|
||||||
|
|
||||||
PROJECT_DIR = Path(__file__).resolve().parent.parent
|
PROJECT_DIR = Path(__file__).resolve().parent.parent
|
||||||
BASE_DIR = PROJECT_DIR.parent
|
BASE_DIR = PROJECT_DIR.parent
|
||||||
|
|
||||||
|
|
||||||
|
dotenv.load_dotenv(BASE_DIR / ".env")
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
||||||
|
|
||||||
@@ -49,6 +55,7 @@ INSTALLED_APPS = [
|
|||||||
"allauth",
|
"allauth",
|
||||||
"allauth.account",
|
"allauth.account",
|
||||||
"allauth.socialaccount",
|
"allauth.socialaccount",
|
||||||
|
"allauth.socialaccount.providers.github",
|
||||||
"tailwind",
|
"tailwind",
|
||||||
"theme",
|
"theme",
|
||||||
]
|
]
|
||||||
@@ -104,6 +111,17 @@ ACCOUNT_SIGNUP_FORM_CLASS = "kursy.forms.SignUpForm"
|
|||||||
|
|
||||||
ACCOUNT_LOGIN_METHODS = ["email", "username"]
|
ACCOUNT_LOGIN_METHODS = ["email", "username"]
|
||||||
|
|
||||||
|
SOCIALACCOUNT_PROVIDERS = {
|
||||||
|
"github": {
|
||||||
|
"APP": {
|
||||||
|
"client_id": os.getenv("GITHUB_CLIENT_ID"),
|
||||||
|
"secret": os.getenv("GITHUB_SECRET"),
|
||||||
|
},
|
||||||
|
"SCOPE": [
|
||||||
|
"read:user",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
WSGI_APPLICATION = "kursy.wsgi.application"
|
WSGI_APPLICATION = "kursy.wsgi.application"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user