fix: use custom profile endpoints for email/password change
This commit is contained in:
@@ -95,31 +95,19 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account (email & password changes via Better Auth)
|
// Account (email & password changes via profile API)
|
||||||
async changePassword(currentPassword: string, newPassword: string): Promise<void> {
|
async changePassword(currentPassword: string, newPassword: string): Promise<void> {
|
||||||
const response = await fetch(`${AUTH_BASE}/api/auth/change-password`, {
|
return this.fetch('/profile/password', {
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json', ...this.authHeaders() },
|
|
||||||
credentials: 'include',
|
|
||||||
body: JSON.stringify({ currentPassword, newPassword }),
|
body: JSON.stringify({ currentPassword, newPassword }),
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
|
||||||
const error = await response.json().catch(() => ({ message: 'Failed to change password' }));
|
|
||||||
throw new Error(error.message || 'Failed to change password');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async changeEmail(newEmail: string): Promise<void> {
|
async changeEmail(newEmail: string): Promise<void> {
|
||||||
const response = await fetch(`${AUTH_BASE}/api/auth/change-email`, {
|
return this.fetch('/profile/email', {
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json', ...this.authHeaders() },
|
|
||||||
credentials: 'include',
|
|
||||||
body: JSON.stringify({ newEmail }),
|
body: JSON.stringify({ newEmail }),
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
|
||||||
const error = await response.json().catch(() => ({ message: 'Failed to change email' }));
|
|
||||||
throw new Error(error.message || 'Failed to change email');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Profile
|
// Profile
|
||||||
|
|||||||
Reference in New Issue
Block a user