From 3b6f493eff27ff7f7bca16a8c69e9578085d3cfb Mon Sep 17 00:00:00 2001 From: Hassan Ali Date: Thu, 21 Nov 2019 14:21:42 -0500 Subject: [PATCH] Log user out if SSO session expired (#11) --- src/components/Authorize/index.jsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/Authorize/index.jsx b/src/components/Authorize/index.jsx index 9a4300d..9098494 100644 --- a/src/components/Authorize/index.jsx +++ b/src/components/Authorize/index.jsx @@ -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); @@ -288,7 +304,7 @@ export default class Authorize extends Component { userInfo: null, }, () => { - this.props.onError && this.props.onError(error); + this.handleLoginError(error); } ); } @@ -349,7 +365,7 @@ export default class Authorize extends Component { userInfo: null, }, () => { - this.props.onError && this.props.onError(error); + this.handleLoginError(error); } ); }