geo/backend/app/schemas/auth.py

74 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import uuid
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, EmailStr, Field
class UserRegister(BaseModel):
email: EmailStr
password: str = Field(min_length=8)
name: str = Field(min_length=1, max_length=100)
class UserLogin(BaseModel):
email: EmailStr
password: str
class ForgotPasswordRequest(BaseModel):
email: EmailStr
class ResetPasswordRequest(BaseModel):
token: str
new_password: str = Field(..., min_length=8)
class VerifyEmailRequest(BaseModel):
email: EmailStr
code: str = Field(..., min_length=6, max_length=6)
class ChangePasswordRequest(BaseModel):
old_password: str
new_password: str = Field(..., min_length=8)
class UpdateProfileRequest(BaseModel):
name: Optional[str] = None
avatar_url: Optional[str] = None
class UserResponse(BaseModel):
id: uuid.UUID
email: str
name: str | None
plan: str
max_queries: int
is_active: bool
email_verified: bool
is_admin: bool
avatar_url: str | None
created_at: datetime
model_config = {"from_attributes": True}
class TokenResponse(BaseModel):
access_token: str
token_type: str
refresh_token: str
user: UserResponse
class RefreshTokenRequest(BaseModel):
refresh_token: str
class AccessTokenResponse(BaseModel):
"""刷新接口返回:新 access_token + 新 refresh_token滑动过期"""
access_token: str
token_type: str
refresh_token: str