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;
|
static contextType = globals;
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!this.context.user) {
|
let userDataResponse = await apiClient.get("/user");
|
||||||
let userDataResponse = await apiClient.get("/user");
|
if (userDataResponse.status === 200) {
|
||||||
if (userDataResponse.status === 200) {
|
this.context.update({ user: userDataResponse.data });
|
||||||
this.context.update({ user: userDataResponse.data });
|
} else if (userDataResponse.status == 401) {
|
||||||
} else if (userDataResponse.status == 401) {
|
this.context.navigate("/signup", { replace: true });
|
||||||
this.context.navigate("/signup", { replace: true });
|
}
|
||||||
}
|
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
|
||||||
} else if (this.context.user.accessLevel < this.props.accessLevel) {
|
|
||||||
this.context.navigate("/", { replace: true });
|
this.context.navigate("/", { replace: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user