Authentication guard will now always refresh user identity.
This commit is contained in:
parent
e7d689cdde
commit
a0a347e0c2
@ -10,14 +10,13 @@ export default class AuthenticationGuard extends React.Component {
|
||||
static contextType = globals;
|
||||
|
||||
async componentDidMount() {
|
||||
if (!this.context.user) {
|
||||
let userDataResponse = await apiClient.get("/user");
|
||||
if (userDataResponse.status === 200) {
|
||||
this.context.update({ user: userDataResponse.data });
|
||||
} else if (userDataResponse.status == 401) {
|
||||
this.context.navigate("/signup", { replace: true });
|
||||
}
|
||||
} else if (this.context.user.accessLevel < this.props.accessLevel) {
|
||||
let userDataResponse = await apiClient.get("/user");
|
||||
if (userDataResponse.status === 200) {
|
||||
this.context.update({ user: userDataResponse.data });
|
||||
} else if (userDataResponse.status == 401) {
|
||||
this.context.navigate("/signup", { replace: true });
|
||||
}
|
||||
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
|
||||
this.context.navigate("/", { replace: true });
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user