20 lines
785 B
Python
20 lines
785 B
Python
from django.db import models
|
|
|
|
from django.contrib.auth.models import AbstractUser
|
|
|
|
class CustomUser(AbstractUser):
|
|
# เพิ่มฟิลด์ที่ต้องการ เช่น phone_number
|
|
phone_number = models.CharField(max_length=20, blank=True, null=True, unique=True)
|
|
email = models.EmailField(unique=True)
|
|
|
|
# เพิ่มฟิลด์ Role สำหรับ RBAC ที่กำหนดเอง
|
|
ROLE_CHOICES = [
|
|
('ADMIN', 'Administrator'),
|
|
('OPERATOR', 'Operator'),
|
|
('VIEWER', 'Viewer'),
|
|
]
|
|
role = models.CharField(max_length=20, choices=ROLE_CHOICES, default='VIEWER')
|
|
|
|
# ไม่ต้องเปลี่ยนส่วนอื่นๆ ถ้าสืบทอดจาก AbstractUser
|
|
pass
|