mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
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:
parent
a4dd1611d1
commit
7e330bfb67
1 changed files with 18 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue