fix: use custom profile endpoints for email/password change

This commit is contained in:
2026-01-28 21:55:39 +00:00
parent a3d4f09291
commit 726bbf27ca

View File

@@ -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> {
const response = await fetch(`${AUTH_BASE}/api/auth/change-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...this.authHeaders() },
credentials: 'include',
return this.fetch('/profile/password', {
method: 'PUT',
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> {
const response = await fetch(`${AUTH_BASE}/api/auth/change-email`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...this.authHeaders() },
credentials: 'include',
return this.fetch('/profile/email', {
method: 'PUT',
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