Skip to content

Commit

Permalink
fix: add more reusable settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Sep 21, 2023
1 parent 4516d80 commit 8bed5a8
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 4 deletions.
41 changes: 37 additions & 4 deletions codeforlife/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
# https://docs.djangoproject.com/en/3.2/ref/settings/#authentication-backends

AUTHENTICATION_BACKENDS = [
"codeforlife.user.auth_backends.EmailAndPasswordBackend",
"codeforlife.user.auth_backends.UserIdAndLoginIdBackend",
"codeforlife.user.auth_backends.UsernameAndPasswordAndClassIdBackend",
"codeforlife.user.auth.backends.EmailAndPasswordBackend",
"codeforlife.user.auth.backends.UserIdAndLoginIdBackend",
"codeforlife.user.auth.backends.UsernameAndPasswordAndClassIdBackend",
]

# Sessions
Expand All @@ -52,7 +52,7 @@
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.AutoField" # TODO: use BugAutoField
DEFAULT_AUTO_FIELD = "django.db.models.AutoField" # TODO: use BigAutoField

# CSRF
# https://docs.djangoproject.com/en/3.2/ref/csrf/
Expand Down Expand Up @@ -84,3 +84,36 @@
"handlers": ["console"],
},
}

# URLs
# https://docs.djangoproject.com/en/4.2/ref/settings/#root-urlconf

ROOT_URLCONF = "service.urls"

# App
# https://docs.djangoproject.com/en/4.2/ref/settings/#wsgi-application

WSGI_APPLICATION = "service.wsgi.application"

# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

# TODO: replace with custom validators:
# 1. codeforlife.user.auth.password_validators.TeacherPasswordValidator
# 2. codeforlife.user.auth.password_validators.DependentStudentPasswordValidator
# 3. codeforlife.user.auth.password_validators.IndependentStudentPasswordValidator
# 4. codeforlife.user.auth.password_validators.CommonPasswordValidator
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
1 change: 1 addition & 0 deletions codeforlife/user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import authentication as auth
Empty file.
File renamed without changes.
Empty file.
3 changes: 3 additions & 0 deletions codeforlife/user/authentication/password_validators/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO: https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#writing-your-own-validator
class CommonPasswordValidator:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO: https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#writing-your-own-validator
class DependentStudentPasswordValidator:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO: https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#writing-your-own-validator
class IndependentStudentPasswordValidator:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO: https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#writing-your-own-validator
class TeacherPasswordValidator:
pass

0 comments on commit 8bed5a8

Please sign in to comment.