Skip to content

Commit 6afc604

Browse files
author
Sachin Maheshwari
committed
sliently retrying login if auth0 session avaialble
1 parent 9ddb266 commit 6afc604

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

web-assets/js/setupAuth0WithRedirect.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,31 @@ const authSetup = function () {
515515
if (token && !isTokenExpired(token)) {
516516
informIt(success);
517517
} else if (!token) {
518-
informIt(failed);
518+
const auth0Session = getCookie('auth0.is.authenticated');
519+
logger('auth0 session available ?', auth0Session);
520+
if (auth0Session) {
521+
logger('auth session true', 1);
522+
if (!auth0) {
523+
createAuth0Client({
524+
domain: domain,
525+
client_id: clientId,
526+
cacheLocation: useLocalStorage
527+
? 'localstorage'
528+
: 'memory',
529+
useRefreshTokens: useRefreshTokens
530+
}).then(function (newAuth0Obj) {
531+
getToken(newAuth0Obj);
532+
}).catch(function (e) {
533+
logger("Error occurred in re-initializing auth0 object: ", e);
534+
informIt(failed);
535+
});
536+
} else {
537+
getToken(auth0);
538+
}
539+
} else {
540+
informIt(failed);
541+
}
542+
519543
} else {
520544
if (auth0) {
521545
getToken(auth0);

0 commit comments

Comments
 (0)