feat: Addition of authentication and user management systems
This commit is contained in:
21
app/api/v1/schemas/token.py
Normal file
21
app/api/v1/schemas/token.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Token
|
||||
# ----------------------------------------------------------------------
|
||||
class TokenRequest(BaseModel):
|
||||
username: str = Field(..., min_length=3, max_length=30)
|
||||
password: str
|
||||
|
||||
@field_validator("username")
|
||||
def all_allowed_chars(cls, v):
|
||||
for v_char in v:
|
||||
if not v_char in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_":
|
||||
raise ValueError("username can only contain a-z, A-Z, 0-9 and _")
|
||||
return v
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
Reference in New Issue
Block a user