website/lib/models/auth.ts

57 lines
1.3 KiB
TypeScript
Raw Normal View History

// Authentication Response Models
export interface AuthTokens {
access: string;
refresh: string;
}
export interface User {
id: number;
email: string;
first_name: string;
last_name: string;
phone_number?: string;
is_admin?: boolean;
isAdmin?: boolean; // API uses camelCase
is_staff?: boolean;
isStaff?: boolean; // API uses camelCase
is_superuser?: boolean;
isSuperuser?: boolean; // API uses camelCase
is_verified?: boolean;
isVerified?: boolean; // API uses camelCase
is_active?: boolean;
isActive?: boolean; // API uses camelCase
date_joined?: string;
last_login?: string;
created_at?: string;
updated_at?: string;
}
export interface AuthResponse {
message?: string;
access?: string; // Tokens can be at root level
refresh?: string; // Tokens can be at root level
tokens?: AuthTokens; // Or nested in tokens object
user?: User;
detail?: string;
error?: string;
}
export interface ApiError {
detail?: string;
message?: string;
error?: string;
email?: string[];
password?: string[];
password2?: string[];
otp?: string[];
[key: string]: string | string[] | undefined;
}
// Token Storage Keys
export const TOKEN_STORAGE_KEYS = {
ACCESS_TOKEN: "auth_access_token",
REFRESH_TOKEN: "auth_refresh_token",
USER: "auth_user",
} as const;