first commit
This commit is contained in:
94
lib/types/auth.ts
Normal file
94
lib/types/auth.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Auth API types (backend /api/v1/auth/*)
|
||||
* @see Temp/login_register.md
|
||||
*/
|
||||
|
||||
/** User object in login response */
|
||||
export interface AuthUserLogin {
|
||||
id: number
|
||||
email: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
username: string
|
||||
is_admin: boolean
|
||||
}
|
||||
|
||||
/** User object in /me response (no username in doc, but same shape) */
|
||||
export interface AuthUserMe {
|
||||
id: number
|
||||
email: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
is_admin: boolean
|
||||
}
|
||||
|
||||
/** User object in register response */
|
||||
export interface AuthUserRegister {
|
||||
id: number
|
||||
email: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
username: string
|
||||
email_verified: boolean
|
||||
is_admin: boolean
|
||||
}
|
||||
|
||||
// --- Login ---
|
||||
export interface LoginRequest {
|
||||
email: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
access_token: string
|
||||
refresh_token: string
|
||||
user: AuthUserLogin
|
||||
}
|
||||
|
||||
// --- Me ---
|
||||
export interface MeResponse {
|
||||
user: AuthUserMe
|
||||
}
|
||||
|
||||
// --- Refresh ---
|
||||
export interface RefreshRequest {
|
||||
refresh_token: string
|
||||
}
|
||||
|
||||
export interface RefreshResponse {
|
||||
access_token: string
|
||||
refresh_token: string
|
||||
}
|
||||
|
||||
// --- Register ---
|
||||
export interface RegisterRequest {
|
||||
email: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
password: string
|
||||
username: string
|
||||
}
|
||||
|
||||
/** Client sends turnstile_token to our proxy; backend receives only RegisterRequest */
|
||||
export interface RegisterRequestWithTurnstile extends RegisterRequest {
|
||||
turnstile_token: string
|
||||
}
|
||||
|
||||
export interface RegisterResponse {
|
||||
message: string
|
||||
user: AuthUserRegister
|
||||
}
|
||||
|
||||
// --- Resend verification ---
|
||||
export interface ResendVerificationRequest {
|
||||
email: string
|
||||
}
|
||||
|
||||
export interface ResendVerificationResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
// --- Verify email ---
|
||||
export interface VerifyEmailResponse {
|
||||
message: string
|
||||
}
|
||||
Reference in New Issue
Block a user