Skip to content

Commit

Permalink
Merge pull request #5326 from kiva/MP-245-fe-fix-issue-with-page-show…
Browse files Browse the repository at this point in the history
…n-after-session-timeout

fix: add check for new access_denied error
  • Loading branch information
dyersituations committed May 21, 2024
2 parents 3452fac + 5573ca6 commit c5bd105
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion server/auth-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ module.exports = function authRouter(config = {}) {
// Handle errors
if (req.query.error && !silentAuth) {
// Re-attempt login with the login form forced to display if unauthorized error happened
if (req.query.error === 'unauthorized') {
if (req.query.error === 'unauthorized'
|| req.query.error_description?.toLowerCase() === 'session too old, login required'
) {
req.query = {}; // Remove query params from previous auth attempt
return passport.authenticate('auth0', {
audience: config.auth0.apiAudience,
Expand Down
7 changes: 5 additions & 2 deletions src/util/KvAuth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ export default class KvAuth0 {
this.webAuth.checkSession({}, (err, result) => {
if (err) {
this[setAuthData]();
if (err.error === 'login_required' || err.error === 'unauthorized') {
if (err.error === 'login_required'
|| err.error === 'unauthorized'
|| err.error === 'access_denied'
) {
// User is not logged in, so continue without authentication
this[noteLoggedOut]();
resolve();
Expand Down Expand Up @@ -364,5 +367,5 @@ export const MockKvAuth0 = {
checkSession: () => Promise.resolve({}),
popupLogin: () => Promise.resolve({}),
popupCallback: () => Promise.resolve({}),
onError: () => {},
onError: () => { },
};

0 comments on commit c5bd105

Please sign in to comment.