Always show the login page, regardless of OIDC status
This commit is contained in:
committed by
Aditya Chandel
parent
9b1eb42381
commit
46db40247c
@@ -16,58 +16,59 @@ export function initializeAuthFactory() {
|
||||
|
||||
return new Promise<void>((resolve) => {
|
||||
const sub = appSettingsService.appSettings$.subscribe(settings => {
|
||||
if (settings) {
|
||||
if (settings.oidcEnabled && settings.oidcProviderDetails) {
|
||||
const details = settings.oidcProviderDetails;
|
||||
if (!settings) return;
|
||||
|
||||
oauthService.configure({
|
||||
issuer: details.issuerUri,
|
||||
clientId: details.clientId,
|
||||
scope: 'openid profile email offline_access',
|
||||
redirectUri: window.location.origin + '/oauth2-callback',
|
||||
responseType: 'code',
|
||||
showDebugInformation: false,
|
||||
requireHttps: false,
|
||||
strictDiscoveryDocumentValidation: false,
|
||||
sub.unsubscribe();
|
||||
|
||||
if (settings.oidcEnabled && settings.oidcProviderDetails) {
|
||||
const details = settings.oidcProviderDetails;
|
||||
|
||||
oauthService.configure({
|
||||
issuer: details.issuerUri,
|
||||
clientId: details.clientId,
|
||||
scope: 'openid profile email offline_access',
|
||||
redirectUri: window.location.origin + '/oauth2-callback',
|
||||
responseType: 'code',
|
||||
showDebugInformation: false,
|
||||
requireHttps: false,
|
||||
strictDiscoveryDocumentValidation: false,
|
||||
});
|
||||
|
||||
oauthService.loadDiscoveryDocumentAndTryLogin()
|
||||
.then(() => {
|
||||
if (oauthService.hasValidAccessToken()) {
|
||||
console.log('[OIDC] Valid access token found');
|
||||
oauthService.setupAutomaticSilentRefresh();
|
||||
websocketInitializer(authService);
|
||||
} else {
|
||||
console.warn('[OIDC] No valid access token. Will proceed to app and show login page.');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('[OIDC] Failed to load discovery document or login:', err);
|
||||
authInitService.setOidcFailed(true);
|
||||
})
|
||||
.finally(() => {
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
});
|
||||
|
||||
oauthService.loadDiscoveryDocumentAndTryLogin()
|
||||
.then(() => {
|
||||
console.log('[OIDC] Discovery document loaded and login attempted');
|
||||
if (oauthService.hasValidAccessToken()) {
|
||||
console.log('[OIDC] Valid access token found after tryLogin');
|
||||
router.navigate(['/dashboard']);
|
||||
oauthService.setupAutomaticSilentRefresh();
|
||||
websocketInitializer(authService);
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
} else {
|
||||
console.log('[OIDC] No valid access token found, attempting silent login with prompt=none');
|
||||
oauthService.initCodeFlow();
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
authInitService.markAsInitialized();
|
||||
console.error(
|
||||
'OIDC initialization failed: Unable to complete OpenID Connect discovery or login. ' +
|
||||
'This may be due to an incorrect issuer URL, client ID, or network issue. ' +
|
||||
'Falling back to local login. Details:', err
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
} else if (settings.remoteAuthEnabled) {
|
||||
authService.remoteLogin().subscribe({
|
||||
next: () => {
|
||||
resolve();
|
||||
},
|
||||
error: resolve
|
||||
});
|
||||
} else {
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
}
|
||||
sub.unsubscribe();
|
||||
} else if (settings.remoteAuthEnabled) {
|
||||
authService.remoteLogin().subscribe({
|
||||
next: () => {
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
},
|
||||
error: err => {
|
||||
console.error('[Remote Login] failed:', err);
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
authInitService.markAsInitialized();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user