Files
gridpilot.gg/apps/website/lib/mutations/auth/ForgotPasswordMutation.ts
2026-01-16 01:00:03 +01:00

30 lines
1.0 KiB
TypeScript

/**
* 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);
if (result.isErr()) {
return Result.err(result.getError().message);
}
return Result.ok(result.unwrap());
} catch (error: any) {
const errorMessage = error instanceof Error ? error.message : 'Failed to send reset link';
return Result.err(errorMessage);
}
}
}