This commit is contained in:
2025-12-01 19:28:49 +01:00
parent 98a09a3f2b
commit 086fdc1ea1
8 changed files with 406 additions and 86 deletions

View File

@@ -171,22 +171,24 @@ export function setupIpcHandlers(mainWindow: BrowserWindow): void {
return { success: false, error: connectionResult.error };
}
logger.info('Browser connection established');
const checkAuthUseCase = container.getCheckAuthenticationUseCase();
if (checkAuthUseCase) {
const authResult = await checkAuthUseCase.execute();
const authResult = await checkAuthUseCase.execute({
verifyPageContent: true,
});
if (authResult.isOk()) {
const authState = authResult.unwrap();
if (authState !== AuthenticationState.AUTHENTICATED) {
logger.warn('Not authenticated - automation cannot proceed', { authState });
logger.warn('Not authenticated or session expired - automation cannot proceed', { authState });
return {
success: false,
error: 'Not authenticated. Please login first.',
error: 'Not authenticated or session expired. Please login first.',
authRequired: true,
authState,
};
}
logger.info('Authentication verified');
logger.info('Authentication verified (cookies and page state)');
} else {
logger.warn('Auth check failed, proceeding anyway', { error: authResult.unwrapErr().message });
}

View File

@@ -142,10 +142,19 @@ export function App() {
if (result.success && result.sessionId) {
setSessionId(result.sessionId);
} else {
setIsRunning(false);
alert(`Failed to start automation: ${result.error}`);
return;
}
setIsRunning(false);
if ((result as any).authRequired) {
const nextAuthState = (result as any).authState as AuthState | undefined;
setAuthState(nextAuthState ?? 'EXPIRED');
setAuthError(result.error ?? 'Authentication required before starting automation.');
return;
}
alert(`Failed to start automation: ${result.error}`);
};
const handleStopAutomation = async () => {