mirror of
https://git.victorphan.net/basketballcantho/ten-project.git
synced 2026-08-05 10:53:10 +07:00
thực hiện phân quyền admin giáo viên và học sinh xong
This commit is contained in:
@@ -2,6 +2,8 @@ from datetime import datetime
|
||||
from pydantic import BaseModel, EmailStr, field_validator
|
||||
import re
|
||||
|
||||
from .models import UserRole, UserStatus
|
||||
|
||||
|
||||
# ── Auth ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -9,6 +11,7 @@ class UserRegister(BaseModel):
|
||||
username: str
|
||||
email: EmailStr
|
||||
password: str
|
||||
role: UserRole = UserRole.student
|
||||
|
||||
@field_validator("username")
|
||||
@classmethod
|
||||
@@ -37,11 +40,21 @@ class UserOut(BaseModel):
|
||||
id: int
|
||||
username: str
|
||||
email: str
|
||||
role: UserRole
|
||||
status: UserStatus
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class UserApprove(BaseModel):
|
||||
status: UserStatus
|
||||
|
||||
|
||||
class UserRoleUpdate(BaseModel):
|
||||
role: UserRole
|
||||
|
||||
|
||||
class TokenPayload(BaseModel):
|
||||
sub: int # user id
|
||||
exp: int
|
||||
|
||||
Reference in New Issue
Block a user