website refactor
This commit is contained in:
26
apps/website/lib/mutations/auth/ForgotPasswordMutation.ts
Normal file
26
apps/website/lib/mutations/auth/ForgotPasswordMutation.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Forgot Password Mutation
|
||||
*
|
||||
* Framework-agnostic mutation for forgot password operations.
|
||||
* Called from Server Actions.
|
||||
*
|
||||
* Pattern: Server Action → Mutation → Service → API Client
|
||||
*/
|
||||
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { AuthService } from '@/lib/services/auth/AuthService';
|
||||
import { ForgotPasswordDTO } from '@/lib/types/generated/ForgotPasswordDTO';
|
||||
import { ForgotPasswordResult } from '@/lib/mutations/auth/types/ForgotPasswordResult';
|
||||
|
||||
export class ForgotPasswordMutation {
|
||||
async execute(params: ForgotPasswordDTO): Promise<Result<ForgotPasswordResult, string>> {
|
||||
try {
|
||||
const authService = new AuthService();
|
||||
const result = await authService.forgotPassword(params);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : 'Failed to send reset link';
|
||||
return Result.err(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user