Files
Salon/backend/apps/accounts/admin.py
T
mohd 46af911a06 I proceeded with Phase 1 step 1 (phone-first auth + OTP hardening) and updated the plan context. Here’s the current state and the next steps.
What I implemented

Phone-first auth endpoints with OTP → JWT issuance.
views.py
urls.py
Phone normalization (KSA-focused, E.164 or Saudi mobile) and validation.
phone.py
serializers.py
OTP protections: rate limit, resend cooldown, attempt counting.
otp.py
models.py
Email is now optional to allow phone-only users.
models.py
0002_phone_auth_fields.py
Admin OTP visibility improved.
admin.py
Risks updated.
risks.md
2026-02-27 15:57:09 +03:00

43 lines
1.3 KiB
Python

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from apps.accounts.models import PhoneOTP, User
@admin.register(User)
class UserAdmin(DjangoUserAdmin):
model = User
list_display = ("email", "phone_number", "role", "is_staff", "is_phone_verified")
list_filter = ("role", "is_staff", "is_phone_verified")
ordering = ("email",)
search_fields = ("email", "phone_number")
fieldsets = (
(None, {"fields": ("email", "password")}),
("Personal", {"fields": ("first_name", "last_name", "phone_number")}),
("Roles", {"fields": ("role", "is_phone_verified")}),
("Permissions", {"fields": ("is_active", "is_staff", "is_superuser", "groups", "user_permissions")}),
("Dates", {"fields": ("last_login",)}),
)
add_fieldsets = (
(None, {
"classes": ("wide",),
"fields": ("email", "password1", "password2", "role"),
}),
)
@admin.register(PhoneOTP)
class PhoneOTPAdmin(admin.ModelAdmin):
list_display = (
"phone_number",
"channel",
"purpose",
"provider",
"created_at",
"expires_at",
"verified_at",
"attempt_count",
)
list_filter = ("channel", "purpose", "provider")
search_fields = ("phone_number",)