From 726bbf27cab6de08118a2bc15a5ac9615b204bee Mon Sep 17 00:00:00 2001 From: Hammer Date: Wed, 28 Jan 2026 21:55:39 +0000 Subject: [PATCH] fix: use custom profile endpoints for email/password change --- src/lib/api.ts | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index fd4ca1e..8339ca3 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -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 { - 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 { - 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