From 603225a0de7a1787845df1cb1c6564d5339b5564 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Mon, 24 Jul 2023 12:51:55 +0200 Subject: [PATCH] add auth user pydantic schemas --- app/schemas/user.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/schemas/user.py diff --git a/app/schemas/user.py b/app/schemas/user.py new file mode 100644 index 0000000..0289be0 --- /dev/null +++ b/app/schemas/user.py @@ -0,0 +1,34 @@ +from uuid import UUID + +from pydantic import BaseModel, Field, EmailStr, ConfigDict + +config = ConfigDict(from_attributes=True) + + +# TODO: add pydantic field validator for strong password +class UserSchema(BaseModel): + model_config = config + email: EmailStr = Field(title="User’s email", description="User’s email") + first_name: str = Field(title="User’s first name", description="User’s first name") + last_name: str = Field(title="User’s last name", description="User’s last name") + password: str = Field(title="User’s password", description="User’s password") + + +class UserResponse(BaseModel): + uuid: UUID = Field(title="User’s id", description="User’s id") + email: EmailStr = Field(title="User’s email", description="User’s email") + first_name: str = Field(title="User’s first name", description="User’s first name") + last_name: str = Field(title="User’s last name", description="User’s last name") + access_token: str = Field(title="User’s token", description="User’s token") + + +class TokenResponse(BaseModel): + access_token: str = Field(title="User’s access token", description="User’s access token") + token_type: str = Field(title="User’s token type", description="User’s token type") + + +class UserLogin(BaseModel): + model_config = config + email: EmailStr = Field(title="User’s email", description="User’s email") + password: str = Field(title="User’s password", description="User’s password") +