Skip to content

Commit

Permalink
Add internal model
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed May 29, 2024
1 parent 9e3b9be commit e640362
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Internal Models to help abstract and encapsulate the authentication process
"""

import enum
from dataclasses import dataclass

from pydantic import BaseModel


class UserCredentials(BaseModel):
"""
Pydantic model for user credentials. Allows FastAPI to validate the object recieved in the login endpoint
"""

username: str
password: str


class Role(enum.Enum):
"""
Role Enum to differentiate between user and staff. It is assumed staff will see all data
"""

STAFF = "staff"
USER = "user"


@dataclass
class User:
"""
Internal User Model for packing JWTs
"""

user_number: int

@property
def role(self) -> Role:
# TODO: Actually assign a role
return Role.USER

0 comments on commit e640362

Please sign in to comment.