mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-21 22:46:41 +02:00
♻️ refactor: migrate manacore-web from Supabase to mana-core-auth
- Add password reset functionality to mana-core-auth using Better Auth - Add forgot-password and reset-password endpoints with DTOs - Update shared-auth package with resetPassword method and endpoint - Update manacore-web auth store with resetPassword method - Refactor reset-password pages to use mana-core-auth instead of Supabase - Remove Supabase dependencies from manacore-web package.json - Remove Supabase server code (hooks.server.ts, supabase.ts, API routes) - Update Dockerfile to remove shared-supabase dependency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
48c5cb48f7
commit
ee091c4b10
23 changed files with 357 additions and 639 deletions
|
|
@ -39,6 +39,7 @@ const DEFAULT_ENDPOINTS: AuthEndpoints = {
|
|||
refresh: '/api/v1/auth/refresh',
|
||||
validate: '/api/v1/auth/validate',
|
||||
forgotPassword: '/api/v1/auth/forgot-password',
|
||||
resetPassword: '/api/v1/auth/reset-password',
|
||||
googleSignIn: '/api/v1/auth/google-signin',
|
||||
appleSignIn: '/api/v1/auth/apple-signin',
|
||||
credits: '/api/v1/credits/balance',
|
||||
|
|
@ -192,6 +193,41 @@ export function createAuthService(config: AuthServiceConfig) {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset password with token
|
||||
*/
|
||||
async resetPassword(token: string, newPassword: string): Promise<AuthResult> {
|
||||
try {
|
||||
const response = await fetch(`${baseUrl}${endpoints.resetPassword}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ token, newPassword }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
|
||||
if (errorData.message?.includes('expired')) {
|
||||
return { success: false, error: 'Reset link has expired. Please request a new one.' };
|
||||
}
|
||||
|
||||
if (errorData.message?.includes('invalid')) {
|
||||
return { success: false, error: 'Invalid reset link. Please request a new one.' };
|
||||
}
|
||||
|
||||
return { success: false, error: errorData.message || 'Password reset failed' };
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error resetting password:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Unknown error during password reset',
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh the authentication tokens
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ export interface AuthEndpoints {
|
|||
refresh: string;
|
||||
validate: string;
|
||||
forgotPassword: string;
|
||||
resetPassword: string;
|
||||
googleSignIn: string;
|
||||
appleSignIn: string;
|
||||
credits: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue