27 lines
920 B
TypeScript
27 lines
920 B
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);
|
|
return Result.ok(result);
|
|
} catch (error) {
|
|
const errorMessage = error instanceof Error ? error.message : 'Failed to reset password';
|
|
return Result.err(errorMessage);
|
|
}
|
|
}
|
|
}
|