fix issue with authentication redirect loop

This commit is contained in:
Rick Watson committed 2019-06-03 21:32:54 +01:00
1 parent 3157b7d3ef
commit 0da88878d5
4 files changed
+28 -20

No files matched your search

@@ -47,7 +47,7 @@ export function redirectingAuthorizedFetch(url, params) {
return new Promise(function (resolve, reject) {
authorizedFetch(url, params).then(response => {
if (response.status === 401) {
history.push("/");
history.push("/unauthorized");
} else {
resolve(response);
}
@@ -89,11 +89,11 @@ class AuthenticationWrapper extends React.Component {
signIn = (accessToken) => {
try {
this.setState({ context: { ...this.state.context, user: jwtDecode(accessToken) } });
localStorage.setItem(ACCESS_TOKEN, accessToken);
this.setState({ context: { ...this.state.context, user: jwtDecode(accessToken) } });
} catch (err) {
this.setState({ initialized: true, context: { ...this.state.context, user: undefined } });
this.props.raiseNotification("Failed to parse JWT " + err.message);
throw new Error("Failed to parse JWT " + err.message);
}
}