I’m using express-openid-connect
to manage authentication and maintain sessions in our Node.js application.
Currently, when both our app session and the Okta session are valid, everything works fine. However, when the session on our side expires, we use the isAuthenticated
function from the package to check for a valid session. If it returns false
, we redirect the user to the login page.
On the login page, when the user enters their email in login page, we call the login flow using /login
. We get redirected to okta login Since there’s already an active session on the Okta side, it automatically grants a new token and redirects back to our app—even if the user enters a different email than the one associated with the Okta session. This causes a mismatch where a different user ends up being logged in.
What I want to do is: when our app loads and detects no valid session on our side, check if there is still a valid Okta session, and if so, redirect to Okta to silently refresh the session or prompt a proper login.
How can I achieve this with express-openid-connect
?