30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
/**
|
|
* Reset Password Mutation
|
|
*
|
|
* Framework-agnostic mutation for reset 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 { ResetPasswordDTO } from '@/lib/types/generated/ResetPasswordDTO';
|
|
import { ResetPasswordResult } from '@/lib/mutations/auth/types/ResetPasswordResult';
|
|
|
|
export class ResetPasswordMutation {
|
|
async execute(params: ResetPasswordDTO): Promise<Result<ResetPasswordResult, string>> {
|
|
try {
|
|
const authService = new AuthService();
|
|
const result = await authService.resetPassword(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 reset password';
|
|
return Result.err(errorMessage);
|
|
}
|
|
}
|
|
}
|