Prueba fallida con checkAuthIncludingServer()
This commit is contained in:
@@ -11,15 +11,16 @@ export function configureAuth(oidcConfigService: OidcConfigService): () => Promi
|
||||
redirectUrl: window.location.origin,
|
||||
postLogoutRedirectUri: window.location.origin,
|
||||
clientId: 'okupamicoche-frontend-angular',
|
||||
scope: 'openid profile offline_access',
|
||||
scope: 'openid profile',
|
||||
responseType: 'code',
|
||||
silentRenew: true,
|
||||
useRefreshToken: true,
|
||||
// useRefreshToken: true,
|
||||
silentRenewUrl: `${window.location.origin}/silent-renew.html`,
|
||||
renewTimeBeforeTokenExpiresInSeconds: 30,
|
||||
tokenRefreshInSeconds: 20,
|
||||
ignoreNonceAfterRefresh: true, // El refresh token está fallando si no se ignora el Nonce
|
||||
secureRoutes: [TRAVEL_API_URL, USER_API_URL],
|
||||
storage: localStorage,
|
||||
// storage: localStorage,
|
||||
logLevel: LogLevel.Warn
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,13 +53,12 @@ export class AuthService {
|
||||
this.userSubject.next(User.fromClaims(claims));
|
||||
});
|
||||
|
||||
return this.oidcSecurityService.checkAuth().toPromise().then((auth) => {
|
||||
console.log('AUTH INITIALIZED result=', auth);
|
||||
|
||||
if (auth) {
|
||||
if (sessionStorage.getItem('chatLoginInProcess') === 'true') {
|
||||
sessionStorage.removeItem('chatLoginInProcess');
|
||||
if ((sessionStorage.getItem('chatLoginInProcess') === 'true') || chatLoginToken) {
|
||||
sessionStorage.removeItem('chatLoginInProcess');
|
||||
|
||||
return this.oidcSecurityService.checkAuth().toPromise().then((auth) => {
|
||||
console.log('AUTH INITIALIZED result=', auth);
|
||||
if (auth) {
|
||||
if (chatLoginToken) {
|
||||
console.log('chatLoginToken=' + chatLoginToken);
|
||||
this.chatService.login(chatLoginToken);
|
||||
@@ -73,15 +72,23 @@ export class AuthService {
|
||||
|
||||
return AuthState.Logged;
|
||||
}
|
||||
else {
|
||||
|
||||
return AuthState.NotLogged;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.oidcSecurityService.checkAuthIncludingServer().toPromise().then((auth) => {
|
||||
console.log('AUTH INITIALIZED result=', auth);
|
||||
|
||||
if (auth) {
|
||||
console.log('GO TO SSO LOGIN');
|
||||
sessionStorage.setItem('chatLoginInProcess', 'true');
|
||||
this.chatService.goToSsoLogin();
|
||||
return AuthState.ChatLoggingInProcess;
|
||||
}
|
||||
}
|
||||
|
||||
return AuthState.NotLogged;
|
||||
});
|
||||
return AuthState.NotLogged;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
src/silent-renew.html
Normal file
21
src/silent-renew.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<base href="./" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>silent-renew</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
/* The parent window hosts the Angular application */
|
||||
var parent = window.parent;
|
||||
/* Send the id_token information to the oidc message handler */
|
||||
var event = new CustomEvent('oidc-silent-renew-message', { detail: window.location });
|
||||
parent.dispatchEvent(event);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user