Skip to content

Commit 3b6f493

Browse files
authored
Log user out if SSO session expired (#11)
1 parent b205a40 commit 3b6f493

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/components/Authorize/index.jsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ export default class Authorize extends Component {
160160
}
161161
}
162162

163+
handleLoginError(error) {
164+
// https://auth0.com/docs/api-auth/tutorials/silent-authentication#error-response
165+
if (
166+
error.error === 'consent_required' ||
167+
error.error === 'login_required' ||
168+
error.error === 'interaction_required'
169+
) {
170+
localStorage.removeItem(CHANNEL);
171+
localStorage.removeItem(SESSION);
172+
}
173+
174+
if (this.props.onError) {
175+
this.props.onError(error);
176+
}
177+
}
178+
163179
authCheck(props) {
164180
if (this.renewalTimer) {
165181
clearTimeout(this.renewalTimer);
@@ -288,7 +304,7 @@ export default class Authorize extends Component {
288304
userInfo: null,
289305
},
290306
() => {
291-
this.props.onError && this.props.onError(error);
307+
this.handleLoginError(error);
292308
}
293309
);
294310
}
@@ -349,7 +365,7 @@ export default class Authorize extends Component {
349365
userInfo: null,
350366
},
351367
() => {
352-
this.props.onError && this.props.onError(error);
368+
this.handleLoginError(error);
353369
}
354370
);
355371
}

0 commit comments

Comments
 (0)