Authentication guard will now always refresh user identity.

This commit is contained in:
Harrison Deng 2022-04-07 18:00:14 -05:00
parent e7d689cdde
commit a0a347e0c2

View File

@ -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) {
if (this.context.user && this.context.user.accessLevel < this.props.accessLevel) {
this.context.navigate("/", { replace: true });
}
}