mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 08:56:52 +00:00
refactor: clean up scaffolding backend
This commit is contained in:
+4
-13
@@ -7,13 +7,12 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
class CustomUserManager(BaseUserManager):
|
||||
"""
|
||||
General User Model
|
||||
Creates and saves a User with email and password.
|
||||
"""
|
||||
|
||||
def create_user(self, email, password=None, **extra_fields):
|
||||
if not email:
|
||||
raise ValueError(_("The Email must be set"))
|
||||
# set default activation state as False to enforce email verification
|
||||
extra_fields.setdefault("is_active", False)
|
||||
|
||||
email = self.normalize_email(email)
|
||||
@@ -24,7 +23,7 @@ class CustomUserManager(BaseUserManager):
|
||||
|
||||
def create_superuser(self, email, password, **extra_fields):
|
||||
"""
|
||||
Admin Model
|
||||
Creates a Superuser with email and password.
|
||||
"""
|
||||
extra_fields.update({"is_staff": True, "is_superuser": True, "is_active": True})
|
||||
|
||||
@@ -33,30 +32,22 @@ class CustomUserManager(BaseUserManager):
|
||||
|
||||
class User(AbstractUser):
|
||||
"""
|
||||
Database table structure.
|
||||
Note: We use the default integer ID internally for database performance (joins/indexes)
|
||||
but expose a random 'public_id' (UUID) in URLs and APIs for real privacy.
|
||||
Creates a User with email as primary identifier.
|
||||
Requires manual email verification for activation.
|
||||
"""
|
||||
|
||||
public_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True, db_index=True)
|
||||
|
||||
# Reset default fields
|
||||
username = None
|
||||
first_name = None
|
||||
last_name = None
|
||||
|
||||
full_name = models.CharField(max_length=100)
|
||||
email = models.EmailField(_("email address"), unique=True)
|
||||
|
||||
# salt for client-side key derivation
|
||||
kdf_salt = models.CharField(max_length=128, blank=True, null=True)
|
||||
|
||||
# Default is False to enforce email verification
|
||||
is_active = models.BooleanField(default=False)
|
||||
|
||||
objects = CustomUserManager()
|
||||
|
||||
# Login uses email instead of username
|
||||
USERNAME_FIELD = "email"
|
||||
REQUIRED_FIELDS = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user