Improve channel redirect
A channel redirection now only occurs if the current host is listed in one of the channels.
This commit is contained in:
parent
92ca98f59e
commit
09fdf1ed18
1 changed files with 18 additions and 1 deletions
|
@ -10,11 +10,27 @@ function redirect(string $target)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
$isDevEnvironment = defined('ENV_IS_DEV') && true === ENV_IS_DEV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect user based on channel setting
|
||||||
|
*/
|
||||||
|
$isHostInChannel = false;
|
||||||
|
|
||||||
|
/** Determine if host is a defined channel */
|
||||||
|
foreach (CHANNELS as $channel) {
|
||||||
|
if ($channel['host'] === $_SERVER['HTTP_HOST']) {
|
||||||
|
$isHostInChannel = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Determine channel to redirect to */
|
||||||
if (
|
if (
|
||||||
defined('CHANNELS')
|
defined('CHANNELS')
|
||||||
&& is_array(CHANNELS)
|
&& is_array(CHANNELS)
|
||||||
&& isset($user->channel)
|
&& isset($user->channel)
|
||||||
&& '127.0.0.1' !== $_SERVER['REMOTE_ADDR']
|
&& !$isDevEnvironment
|
||||||
) {
|
) {
|
||||||
$host = null;
|
$host = null;
|
||||||
|
|
||||||
|
@ -22,6 +38,7 @@ function redirect(string $target)
|
||||||
if (
|
if (
|
||||||
$channel['branch'] === $user->channel
|
$channel['branch'] === $user->channel
|
||||||
&& $channel['host'] !== $_SERVER['HTTP_HOST']
|
&& $channel['host'] !== $_SERVER['HTTP_HOST']
|
||||||
|
&& $isHostInChannel
|
||||||
) {
|
) {
|
||||||
$host = $channel['host'];
|
$host = $channel['host'];
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue