-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
saxix
committed
Jul 11, 2024
1 parent
82d9a8c
commit 30c0ffb
Showing
4 changed files
with
41 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ authors = [ | |
{name = "Domenico DiNicola", email = "[email protected]"}, | ||
] | ||
requires-python = ">=3.12" | ||
|
||
dependencies = [ | ||
"Django", | ||
"celery[redis]", | ||
|
@@ -43,9 +44,17 @@ dependencies = [ | |
"requests>=2.32.3", | ||
] | ||
|
||
|
||
[build-system] | ||
requires = ["pdm-backend"] | ||
build-backend = "pdm.backend" | ||
|
||
[tool.pdm.build] | ||
includes = [] | ||
|
||
[tool.pdm] | ||
distribution = true | ||
|
||
[tool.pdm.dev-dependencies] | ||
dev = [ | ||
"black", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import TYPE_CHECKING, Any, Optional | ||
|
||
from django.conf import settings | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.backends import ModelBackend | ||
|
||
if TYPE_CHECKING: | ||
from django.contrib.auth.models import AbstractBaseUser | ||
from django.http import HttpRequest | ||
|
||
|
||
class AnyUserAuthBackend(ModelBackend): | ||
def authenticate( | ||
self, | ||
request: "Optional[HttpRequest]", | ||
username: str | None = None, | ||
password: str | None = None, | ||
**kwargs: Any, | ||
) -> "AbstractBaseUser | None": | ||
if settings.DEBUG: | ||
user, __ = get_user_model().objects.update_or_create( | ||
username=username, | ||
defaults=dict(is_staff=True, is_active=True, is_superuser=True), | ||
) | ||
return user | ||
return None |