If the user session has expired, update context appropriately.
This commit is contained in:
parent
90040f9049
commit
753669c0af
@ -13,15 +13,16 @@ export default class AuthenticationGuard extends React.Component {
|
||||
let userDataResponse = await apiClient.get("/user");
|
||||
if (userDataResponse.status === 200) {
|
||||
this.context.update({ user: userDataResponse.data });
|
||||
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
|
||||
this.context.navigate("/", { replace: true });
|
||||
}
|
||||
} else if (userDataResponse.status == 401) {
|
||||
this.context.navigate("/signup", { replace: true });
|
||||
this.context.update({ user: null });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
|
||||
this.context.navigate("/", { replace: true });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
Loading…
Reference in New Issue
Block a user