diff --git a/js/components/ascribe_routes/proxy_handler.js b/js/components/ascribe_routes/proxy_handler.js
index c5c60506..06b27422 100644
--- a/js/components/ascribe_routes/proxy_handler.js
+++ b/js/components/ascribe_routes/proxy_handler.js
@@ -41,6 +41,7 @@ export function AuthRedirect({to, when}) {
// and redirect if `true`.
if(exprToValidate) {
window.setTimeout(() => history.replaceState(null, to, query));
+ return true;
// Otherwise there can also be the case that the backend
// wants to redirect the user to a specific route when the user is logged out already
@@ -48,6 +49,7 @@ export function AuthRedirect({to, when}) {
delete query.redirect;
window.setTimeout(() => history.replaceState(null, '/' + redirect, query));
+ return true;
} else if(!exprToValidate && when === 'loggedOut' && redirectAuthenticated) {
/*
@@ -60,7 +62,9 @@ export function AuthRedirect({to, when}) {
* `baseUrl` + `redirectAuthenticated`, as it gets rid of queries as well.
*/
window.location = AppConstants.baseUrl + redirectAuthenticated;
+ return true;
}
+ return false;
};
}
@@ -71,7 +75,7 @@ export function AuthRedirect({to, when}) {
*
* @param {[function]} redirectFn A function that conditionally redirects
*/
-export function ProxyHandler(redirectFn) {
+export function ProxyHandler(...redirectFunctions) {
return (Component) => {
return React.createClass({
displayName: 'ProxyHandler',
@@ -97,7 +101,15 @@ export function ProxyHandler(redirectFn) {
if(!UserStore.isLoading()) {
const { currentUser } = this.state;
const { query } = this.props.location;
- redirectFn(currentUser, query);
+ for(let i = 0; i < redirectFunctions.length; i++) {
+ // if a redirectFunction redirects the user,
+ // it should return `true` and therefore
+ // stop/avoid the execution of all functions
+ // that follow
+ if(redirectFunctions[i](currentUser, query)) {
+ break;
+ }
+ }
}
},
diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js b/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js
new file mode 100644
index 00000000..edaa6663
--- /dev/null
+++ b/js/components/whitelabel/prize/portfolioreview/components/pr_routes/pr_proxy_handler.js
@@ -0,0 +1,26 @@
+'use strict';
+
+import history from '../../../../../../history';
+
+
+export function AuthPrizeRoleRedirect({ to, when }) {
+ if(when.constructor !== Array && when.length) {
+ throw new Error('`when` of AuthPrizeRoleRedirect must be an array containing values');
+ }
+ if(!to && to.indexOf('/') !== -1) {
+ throw new Error('`to` of AuthPrizeRoleRedirect must be defined and contain a valid route');
+ }
+
+ return function(currentUser, query) {
+ const exprToValidate = when
+ .map((role) => currentUser[role])
+ .reduce((a, b) => a || b);
+
+ if(exprToValidate) {
+ window.setTimeout(() => history.replaceState(null, to, query));
+ return true;
+ } else {
+ return false;
+ }
+ };
+}
\ No newline at end of file
diff --git a/js/components/whitelabel/prize/portfolioreview/pr_app.js b/js/components/whitelabel/prize/portfolioreview/pr_app.js
index 7e66c43c..93b1a168 100644
--- a/js/components/whitelabel/prize/portfolioreview/pr_app.js
+++ b/js/components/whitelabel/prize/portfolioreview/pr_app.js
@@ -4,6 +4,7 @@ import React from 'react';
import GlobalNotification from '../../../global_notification';
import Hero from './components/pr_hero';
+import Header from '../../../header';
import UserStore from '../../../../stores/user_store';
import UserActions from '../../../../actions/user_actions';
@@ -42,17 +43,26 @@ let PRApp = React.createClass({
render() {
const { history, children } = this.props;
const { currentUser } = this.state;
+ let style = {};
let subdomain = getSubdomain();
let header;
+
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
header =