aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/users/managers.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyblackbird_cc/users/managers.py')
-rw-r--r--pyblackbird_cc/users/managers.py42
1 files changed, 0 insertions, 42 deletions
diff --git a/pyblackbird_cc/users/managers.py b/pyblackbird_cc/users/managers.py
deleted file mode 100644
index d8beaa4..0000000
--- a/pyblackbird_cc/users/managers.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from typing import TYPE_CHECKING
-
-from django.contrib.auth.hashers import make_password
-from django.contrib.auth.models import UserManager as DjangoUserManager
-
-if TYPE_CHECKING:
- from .models import User # noqa: F401
-
-
-class UserManager(DjangoUserManager["User"]):
- """Custom manager for the User model."""
-
- def _create_user(self, email: str, password: str | None, **extra_fields):
- """
- Create and save a user with the given email and password.
- """
- if not email:
- msg = "The given email must be set"
- raise ValueError(msg)
- email = self.normalize_email(email)
- user = self.model(email=email, **extra_fields)
- user.password = make_password(password)
- user.save(using=self._db)
- return user
-
- def create_user(self, email: str, password: str | None = None, **extra_fields): # type: ignore[override]
- extra_fields.setdefault("is_staff", False)
- extra_fields.setdefault("is_superuser", False)
- return self._create_user(email, password, **extra_fields)
-
- def create_superuser(self, email: str, password: str | None = None, **extra_fields): # type: ignore[override]
- extra_fields.setdefault("is_staff", True)
- extra_fields.setdefault("is_superuser", True)
-
- if extra_fields.get("is_staff") is not True:
- msg = "Superuser must have is_staff=True."
- raise ValueError(msg)
- if extra_fields.get("is_superuser") is not True:
- msg = "Superuser must have is_superuser=True."
- raise ValueError(msg)
-
- return self._create_user(email, password, **extra_fields)