Added missing password API services.

This commit is contained in:
Andrés 2025-10-22 01:29:40 -05:00
parent 7e812733fb
commit 26045484f6
1 changed files with 72 additions and 3 deletions

View File

@ -23,7 +23,6 @@ const MOCK_CREDENTIALS = {
const login = async ({ username, password }) => { const login = async ({ username, password }) => {
await simulateDelay(); await simulateDelay();
// Simulate API call
if ( if (
username === MOCK_CREDENTIALS.username && username === MOCK_CREDENTIALS.username &&
password === MOCK_CREDENTIALS.password password === MOCK_CREDENTIALS.password
@ -55,7 +54,6 @@ const login = async ({ username, password }) => {
const logout = async (token) => { const logout = async (token) => {
await simulateDelay(300); await simulateDelay(300);
// Simulate successful logout
return { return {
data: { message: "Logged out successfully" }, data: { message: "Logged out successfully" },
status: 200, status: 200,
@ -70,7 +68,6 @@ const logout = async (token) => {
const register = async ({ email, password }) => { const register = async ({ email, password }) => {
await simulateDelay(); await simulateDelay();
// Simulate registration
const token = "mock_jwt_token_" + Date.now(); const token = "mock_jwt_token_" + Date.now();
return { return {
@ -126,10 +123,82 @@ const refresh = async (refreshToken) => {
// return POST(AUTH_ENDPOINTS.REFRESH, { refreshToken }); // return POST(AUTH_ENDPOINTS.REFRESH, { refreshToken });
}; };
// Request Password Reset - Send reset email
const requestPasswordReset = async ({ email }) => {
await simulateDelay();
return {
data: {
message: "Password reset email sent. Please check your inbox.",
email,
},
status: 200,
ok: true,
};
// Real API call (commented out for now)
// return POST(AUTH_ENDPOINTS.REQUEST_PASSWORD_RESET, { email });
};
// Reset Password - Set new password with token
const resetPassword = async ({ token, password }) => {
await simulateDelay();
if (token && password.length >= 6) {
return {
data: {
message:
"Password has been reset successfully. You can now log in with your new password.",
},
status: 200,
ok: true,
};
}
return {
data: { message: "Invalid or expired reset token" },
status: 400,
ok: false,
};
// Real API call (commented out for now)
// return POST(AUTH_ENDPOINTS.RESET_PASSWORD, { token, password });
};
// Change Password - Change password while logged in
const changePassword = async ({ currentPassword, newPassword, token }) => {
await simulateDelay();
if (currentPassword === "demo123" && newPassword.length >= 6) {
return {
data: {
message: "Password changed successfully.",
},
status: 200,
ok: true,
};
}
return {
data: { message: "Current password is incorrect" },
status: 400,
ok: false,
};
// Real API call (commented out for now)
// return POST(AUTH_ENDPOINTS.CHANGE_PASSWORD,
// { currentPassword, newPassword },
// { headers: getAuthHeaders(token) }
// );
};
export const AUTH = { export const AUTH = {
login, login,
logout, logout,
register, register,
me, me,
refresh, refresh,
requestPasswordReset,
resetPassword,
changePassword,
}; };