Redirect to student registration update view

Previously requests to /session/ would return a signal to redirect, but we need /session/ to complete registration. So check if we should redirect when we retrieve the session.

Also update this behavior for banned users.
This commit is contained in:
Ray Schamp 2016-07-21 17:14:58 -04:00
parent a4dd1611d1
commit 7e330bfb67

View file

@ -68,19 +68,25 @@ module.exports.refreshSession = function () {
uri: '/session/'
}, function (err, body) {
if (err) return dispatch(module.exports.setSessionError(err));
if (typeof body === 'undefined') return dispatch(module.exports.setSessionError('No session content'));
if (
body.user &&
body.user.banned &&
window.location.pathname !== '/accounts/banned-response/') {
return window.location = '/accounts/banned-response/';
} else if (
body.flags &&
body.flags.must_complete_registration &&
window.location.pathname !== '/classes/complete_registration') {
return window.location = '/classes/complete_registration';
} else {
dispatch(tokenActions.getToken());
dispatch(module.exports.setSession(body));
dispatch(module.exports.setStatus(module.exports.Status.FETCHED));
if (typeof body !== 'undefined') {
if (body.banned) {
return window.location = body.url;
} else {
dispatch(tokenActions.getToken());
dispatch(module.exports.setSession(body));
dispatch(module.exports.setStatus(module.exports.Status.FETCHED));
// get the permissions from the updated session
dispatch(permissionsActions.getPermissions());
return;
}
// get the permissions from the updated session
dispatch(permissionsActions.getPermissions());
return;
}
});
};