1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 00:28:00 +02:00

Fix PR comments

This commit is contained in:
Brett Sun 2015-12-10 11:11:37 +01:00
parent 3461a28f36
commit 9b99e3ae09

View File

@ -4,10 +4,10 @@ import history from '../../../../../../history';
export function AuthPrizeRoleRedirect({ to, when }) {
if(when.constructor !== Array && when.length) {
if (when.constructor !== Array || !when.length) {
throw new Error('`when` of AuthPrizeRoleRedirect must be an array containing values');
}
if(!to && to.indexOf('/') !== -1) {
if (!to || to.indexOf('/') === -1) {
throw new Error('`to` of AuthPrizeRoleRedirect must be defined and contain a valid route');
}
@ -16,11 +16,11 @@ export function AuthPrizeRoleRedirect({ to, when }) {
.map(role => currentUser[role])
.reduce((a, b) => a || b);
if(exprToValidate) {
if (exprToValidate) {
window.setTimeout(() => history.replaceState(null, to, query));
return true;
} else {
return false;
}
};
}
}