
- Phone number authentication with OTP verification - Email/password authentication with secure bcrypt hashing - Third-party OAuth login support for Google and Apple - JWT token-based authentication system - Rate limiting for OTP requests (5/minute) - SQLite database with SQLAlchemy ORM - Comprehensive user model with multiple auth providers - Alembic database migrations setup - API documentation with Swagger/OpenAPI - Health check and system endpoints - Environment configuration with security best practices - Code quality with Ruff linting and formatting Features: - POST /auth/request-otp - Request OTP for phone authentication - POST /auth/verify-otp - Verify OTP and get access token - POST /auth/signup-email - Email signup with password - POST /auth/login-email - Email login authentication - POST /auth/login-google - Google OAuth integration - POST /auth/login-apple - Apple OAuth integration - GET /user/me - Get current authenticated user info - GET / - API information and documentation links - GET /health - Application health check
40 lines
739 B
Python
40 lines
739 B
Python
from pydantic import BaseModel, EmailStr
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from app.models.user import AuthProvider
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: Optional[EmailStr] = None
|
|
phone_number: Optional[str] = None
|
|
name: Optional[str] = None
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: Optional[str] = None
|
|
auth_provider: AuthProvider
|
|
|
|
|
|
class UserUpdate(UserBase):
|
|
pass
|
|
|
|
|
|
class UserInDBBase(UserBase):
|
|
id: int
|
|
auth_provider: AuthProvider
|
|
is_active: bool
|
|
is_verified: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class User(UserInDBBase):
|
|
pass
|
|
|
|
|
|
class UserInDB(UserInDBBase):
|
|
password_hash: Optional[str] = None
|