view data fixes
This commit is contained in:
@@ -6,6 +6,12 @@ import { AuthPageService } from '@/lib/services/auth/AuthPageService';
|
||||
import { ForgotPasswordViewData } from '@/lib/view-data/ForgotPasswordViewData';
|
||||
|
||||
export class ForgotPasswordPageQuery implements PageQuery<ForgotPasswordViewData, URLSearchParams | Record<string, string | string[] | undefined>> {
|
||||
private readonly authService: AuthPageService;
|
||||
|
||||
constructor(authService?: AuthPageService) {
|
||||
this.authService = authService || new AuthPageService();
|
||||
}
|
||||
|
||||
async execute(searchParams: URLSearchParams | Record<string, string | string[] | undefined>): Promise<Result<ForgotPasswordViewData, string>> {
|
||||
// Parse and validate search parameters
|
||||
const parsedResult = SearchParamParser.parseAuth(searchParams);
|
||||
@@ -17,7 +23,7 @@ export class ForgotPasswordPageQuery implements PageQuery<ForgotPasswordViewData
|
||||
|
||||
try {
|
||||
// Use service to process parameters
|
||||
const authService = new AuthPageService();
|
||||
const authService = this.authService;
|
||||
const serviceResult = await authService.processForgotPasswordParams({ returnTo, token });
|
||||
|
||||
if (serviceResult.isErr()) {
|
||||
@@ -27,8 +33,9 @@ export class ForgotPasswordPageQuery implements PageQuery<ForgotPasswordViewData
|
||||
// Transform to ViewData using builder
|
||||
const viewData = ForgotPasswordViewDataBuilder.build(serviceResult.unwrap());
|
||||
return Result.ok(viewData);
|
||||
} catch (error: any) {
|
||||
return Result.err(error.message || 'Failed to execute forgot password page query');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to execute forgot password page query';
|
||||
return Result.err(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user