-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e3b9be
commit e640362
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |