feat: implement authentication flow with login, registration, and OAuth support

This commit is contained in:
JSC
2025-07-26 18:37:47 +02:00
parent 12cb39503b
commit 57429f9414
11 changed files with 924 additions and 1 deletions

49
src/types/auth.ts Normal file
View File

@@ -0,0 +1,49 @@
export interface User {
id: number
email: string
name: string
picture?: string
role: string
credits: number
is_active: boolean
plan: {
id: number
name: string
max_credits: number
features: string[]
}
created_at: string
updated_at: string
}
export interface TokenResponse {
access_token: string
token_type: string
expires_in: number
}
export interface AuthResponse {
user: User
token: TokenResponse
}
export interface LoginRequest {
email: string
password: string
}
export interface RegisterRequest {
email: string
password: string
name: string
}
export interface AuthContextType {
user: User | null
token: string | null
login: (credentials: LoginRequest) => Promise<void>
register: (data: RegisterRequest) => Promise<void>
logout: () => Promise<void>
loading: boolean
setUser?: (user: User | null) => void
}