File size: 1,583 Bytes
050d8f8
1bd7131
 
 
050d8f8
 
1bd7131
050d8f8
 
 
1bd7131
 
 
 
05b100e
1bd7131
 
 
 
 
 
75fb504
1bd7131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75fb504
 
1bd7131
 
 
 
 
 
75fb504
1bd7131
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from pydantic import BaseModel, EmailStr, Field
from typing import Optional

# Pydantic Models for Google OAuth Authentication

class CheckRegistrationRequest(BaseModel):
    """Check if a user_id has completed registration."""
    user_id: str = Field(..., min_length=1, description="Temporary user ID from frontend")


class GoogleAuthRequest(BaseModel):
    """Request with Google ID token from frontend Sign-In."""
    id_token: str = Field(..., min_length=1, description="Google ID token from Sign-In")
    temp_user_id: Optional[str] = Field(None, description="Optional temp user ID for linking")
    client_type: Optional[str] = Field(None, description="Client type: 'web' or 'mobile' (auto-detected if not provided)")


class AuthResponse(BaseModel):
    """Response after successful Google authentication."""
    success: bool
    access_token: str
    refresh_token: str
    user_id: str
    email: str
    name: Optional[str] = None
    credits: int
    is_new_user: bool


class UserInfoResponse(BaseModel):
    """Response containing current user information."""
    user_id: str
    email: str
    name: Optional[str] = None
    credits: int
    profile_picture: Optional[str] = None


class TokenRefreshRequest(BaseModel):
    """Request to refresh an access token."""
    """Request to refresh an access token."""
    token: Optional[str] = Field(None, description="Current refresh token (optional if in cookie)")


class TokenRefreshResponse(BaseModel):
    """Response with refreshed access token."""
    success: bool
    access_token: str
    refresh_token: str