fix: Add missing auth API methods
Build and Deploy / build-and-push (push) Successful in 49s

This commit is contained in:
AI Bot
2026-09-17 08:55:31 +05:30
parent cbf44587aa
commit b7a08b687d
+65
View File
@@ -118,6 +118,71 @@ export const api = {
return data;
},
addUser: async (userData) => {
const res = await fetch(`${API_URL}/users`, {
method: 'POST',
headers: getHeaders(),
body: JSON.stringify(userData)
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
return data;
},
deleteUser: async (id) => {
const res = await fetch(`${API_URL}/users/${id}`, {
method: 'DELETE',
headers: getHeaders()
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
return data;
},
triggerPasswordReset: async (id) => {
const res = await fetch(`${API_URL}/users/${id}/reset-password`, {
method: 'POST',
headers: getHeaders()
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
return data;
},
// Auth Extensions
activateUser: async (token) => {
const res = await fetch(`${API_URL}/auth/activate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token })
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
return data;
},
forgotPassword: async (email) => {
const res = await fetch(`${API_URL}/auth/forgot-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email })
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
return data;
},
resetPassword: async (token, newPassword) => {
const res = await fetch(`${API_URL}/auth/reset-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token, newPassword })
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
return data;
},
// Credits
deductCredit: async () => {
const res = await fetch(`${API_URL}/users/deduct-credit`, {