chore: build
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
// ============================================
|
||||
// api/api.ts - VERSION CORRIGÉE
|
||||
// ============================================
|
||||
// ✅ AuthResponse inclut access_token
|
||||
// ✅ loginUser et registerUser retournent AuthResponse
|
||||
// ✅ sessionStorage (pas localStorage)
|
||||
|
||||
const API_URL = "/api/v1";
|
||||
const BACKEND_URL = "";
|
||||
export function getMediaUrl(url: string): string {
|
||||
@@ -1949,29 +1947,50 @@ export const verify2FA = async (
|
||||
user: data.user,
|
||||
};
|
||||
} catch (error) {
|
||||
return { success: false, message: error instanceof Error ? error.message : "Erreur" };
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : "Erreur",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const get2FAStatus = async (): Promise<{ two_fa_enabled: boolean; telegram_linked: boolean; admin_2fa_enabled: boolean }> => {
|
||||
export const get2FAStatus = async (): Promise<{
|
||||
two_fa_enabled: boolean;
|
||||
telegram_linked: boolean;
|
||||
admin_2fa_enabled: boolean;
|
||||
}> => {
|
||||
const token = sessionStorage.getItem("token");
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/two-fa/status`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!response.ok) return { two_fa_enabled: false, telegram_linked: false, admin_2fa_enabled: false };
|
||||
if (!response.ok)
|
||||
return {
|
||||
two_fa_enabled: false,
|
||||
telegram_linked: false,
|
||||
admin_2fa_enabled: false,
|
||||
};
|
||||
return await safeJson(response);
|
||||
} catch {
|
||||
return { two_fa_enabled: false, telegram_linked: false, admin_2fa_enabled: false };
|
||||
return {
|
||||
two_fa_enabled: false,
|
||||
telegram_linked: false,
|
||||
admin_2fa_enabled: false,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const toggle2FA = async (enabled: boolean): Promise<{ success: boolean; error?: string }> => {
|
||||
export const toggle2FA = async (
|
||||
enabled: boolean,
|
||||
): Promise<{ success: boolean; error?: string }> => {
|
||||
const token = sessionStorage.getItem("token");
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/two-fa/toggle`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify({ enabled }),
|
||||
});
|
||||
const data = await safeJson(response);
|
||||
|
||||
Reference in New Issue
Block a user