Spaces:
Running on T4
Running on T4
Download backend/app/modules/auth/schemas.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/modules/auth/schemas.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/app/modules/auth/schemas.py
-
curl -L -o schemas.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/modules/auth/schemas.py
1.64 kB
| """Auth request and response bodies.""" | |
| from typing import Annotated, Literal | |
| from email_validator import EmailNotValidError, validate_email | |
| from pydantic import AfterValidator, Field | |
| from app.common.schemas import RequestModel, ResponseModel | |
| from app.modules.accounts.schemas import UserOut | |
| def normalize_email(value: str) -> str: | |
| try: | |
| return validate_email(value.strip(), check_deliverability=False).normalized.lower() | |
| except EmailNotValidError as exc: | |
| raise ValueError("Enter a valid email address.") from exc | |
| Email = Annotated[str, Field(max_length=254), AfterValidator(normalize_email)] | |
| Password = Annotated[str, Field(min_length=8, max_length=128)] | |
| Role = Literal["player", "coach"] | |
| class RegisterIn(RequestModel): | |
| email: Email | |
| password: Password | |
| role: Role | |
| class LoginIn(RequestModel): | |
| email: Annotated[str, Field(min_length=1, max_length=254)] | |
| password: Annotated[str, Field(min_length=1, max_length=128)] | |
| class SocialIn(RequestModel): | |
| provider: Literal["apple", "google"] | |
| id_token: Annotated[str, Field(min_length=1, max_length=8192)] | |
| role: Role = "player" | |
| class RefreshIn(RequestModel): | |
| refresh_token: Annotated[str, Field(min_length=1, max_length=256)] | |
| class ForgotPasswordIn(RequestModel): | |
| email: Email | |
| class ResetPasswordIn(RequestModel): | |
| token: Annotated[str, Field(min_length=1, max_length=256)] | |
| password: Password | |
| class TokensOut(ResponseModel): | |
| access_token: str | |
| refresh_token: str | |
| expires_in: int | |
| class AuthOut(ResponseModel): | |
| user: UserOut | |
| tokens: TokensOut | |
| class SocialAuthOut(AuthOut): | |
| is_new: bool | |