Skip to content

Commit 71c14a6

Browse files
author
mohamedachrefhacheni
committed
user_role_system_up
1 parent 83bdb43 commit 71c14a6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

backend/app/models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import uuid
2+
from enum import Enum
23

34
from pydantic import EmailStr
45
from sqlmodel import Field, Relationship, SQLModel
@@ -39,16 +40,20 @@ class UpdatePassword(SQLModel):
3940
new_password: str = Field(min_length=8, max_length=40)
4041

4142

43+
class UserRole(str, Enum):
44+
ADMIN: str = "admin"
45+
USER: str = "user"
46+
4247
# Database model, database table inferred from class name
4348
class User(UserBase, table=True):
4449
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
4550
hashed_password: str
4651
items: list["Item"] = Relationship(back_populates="owner", cascade_delete=True)
52+
role: UserRole = Field(default=UserRole.USER)
53+
54+
55+
4756

48-
class UserRole(str, Enum):
49-
USER = "user"
50-
ADMIN = "admin"
51-
MODERATOR = "moderator"
5257

5358

5459
# Properties to return via API, id is always required

0 commit comments

Comments
 (0)