Skip to content

Commit

Permalink
Log user out if SSO session expired (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
helfi92 authored Nov 21, 2019
1 parent b205a40 commit 3b6f493
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/components/Authorize/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ export default class Authorize extends Component {
}
}

handleLoginError(error) {
// https://auth0.com/docs/api-auth/tutorials/silent-authentication#error-response
if (
error.error === 'consent_required' ||
error.error === 'login_required' ||
error.error === 'interaction_required'
) {
localStorage.removeItem(CHANNEL);
localStorage.removeItem(SESSION);
}

if (this.props.onError) {
this.props.onError(error);
}
}

authCheck(props) {
if (this.renewalTimer) {
clearTimeout(this.renewalTimer);
Expand Down Expand Up @@ -288,7 +304,7 @@ export default class Authorize extends Component {
userInfo: null,
},
() => {
this.props.onError && this.props.onError(error);
this.handleLoginError(error);
}
);
}
Expand Down Expand Up @@ -349,7 +365,7 @@ export default class Authorize extends Component {
userInfo: null,
},
() => {
this.props.onError && this.props.onError(error);
this.handleLoginError(error);
}
);
}
Expand Down

0 comments on commit 3b6f493

Please sign in to comment.