wip
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { IAuthenticationService } from '../ports/IAuthenticationService';
|
||||
import { Result } from '../../shared/result/Result';
|
||||
import { BrowserAuthenticationState } from '../../domain/value-objects/BrowserAuthenticationState';
|
||||
|
||||
/**
|
||||
* Use case for verifying browser shows authenticated page state.
|
||||
* Combines cookie validation with page content verification.
|
||||
*/
|
||||
export class VerifyAuthenticatedPageUseCase {
|
||||
constructor(
|
||||
private readonly authService: IAuthenticationService
|
||||
) {}
|
||||
|
||||
async execute(): Promise<Result<BrowserAuthenticationState>> {
|
||||
try {
|
||||
const result = await this.authService.verifyPageAuthentication();
|
||||
|
||||
if (result.isErr()) {
|
||||
return Result.err(result.error);
|
||||
}
|
||||
|
||||
const browserState = result.unwrap();
|
||||
|
||||
// Log verification result
|
||||
if (browserState.isFullyAuthenticated()) {
|
||||
// Success case - no logging needed in use case
|
||||
} else if (browserState.requiresReauthentication()) {
|
||||
// Requires re-auth - caller should handle
|
||||
}
|
||||
|
||||
return Result.ok(browserState);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return Result.err(new Error(`Page verification failed: ${message}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user