feat: implement authentication flow with login, registration, and OAuth support
This commit is contained in:
49
src/types/auth.ts
Normal file
49
src/types/auth.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user