Files
job-tracker/api/accounts/models.py
T
Marko (Hermes Implementer) 6867a91b67 feat: add user authentication with separate login and register pages
- Custom User model with email as unique identifier (AUTH_USER_MODEL)

- POST /api/auth/register/ with email validation, password min 8 chars, duplicate rejection

- POST /api/auth/login/ returning JWT (access + refresh) tokens

- Passwords hashed via Django's make_password

- React LoginPage and RegisterPage with form validation

- AuthContext with useReducer for auth state management

- Axios API client with JWT token injection

- TypeScript conversion of frontend scaffold
2026-05-26 00:54:27 +00:00

29 lines
735 B
Python

from django.contrib.auth.models import AbstractUser
from django.db import models
class User(AbstractUser):
"""Custom User model using email as the unique identifier."""
email = models.EmailField(
unique=True,
max_length=254,
help_text="Email address used for authentication.",
)
username = models.CharField(
max_length=150,
blank=True,
null=True,
help_text="Optional display name. Not used for authentication.",
)
USERNAME_FIELD = "email"
REQUIRED_FIELDS: list[str] = []
class Meta:
db_table = "accounts_user"
verbose_name = "User"
verbose_name_plural = "Users"
def __str__(self) -> str:
return self.email