Fixed: Login page redirect for guests

This commit is contained in:
Lucas Bartholemy 2016-04-19 15:09:52 +02:00
parent 78e9cb882f
commit b476ca7d0e

View File

@ -55,11 +55,6 @@ class ContentContainerController extends Controller
*/ */
public function init() public function init()
{ {
// Directly redirect guests to login page - if guest access isn't enabled
if (Yii::$app->user->isGuest && \humhub\models\Setting::Get('allowGuestAccess', 'authentication_internal') != 1) {
return Yii::$app->user->loginRequired();
}
$spaceGuid = Yii::$app->request->get('sguid', ''); $spaceGuid = Yii::$app->request->get('sguid', '');
$userGuid = Yii::$app->request->get('uguid', ''); $userGuid = Yii::$app->request->get('uguid', '');
@ -107,10 +102,29 @@ class ContentContainerController extends Controller
throw new HttpException(405, Yii::t('base', 'Module is not on this content container enabled!')); throw new HttpException(405, Yii::t('base', 'Module is not on this content container enabled!'));
} }
return parent::init(); return parent::init();
} }
/**
* @inheritdoc
*/
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
// Directly redirect guests to login page - if guest access isn't enabled
if (Yii::$app->user->isGuest && \humhub\models\Setting::Get('allowGuestAccess', 'authentication_internal') != 1) {
Yii::$app->user->loginRequired();
return false;
}
return true;
}
return false;
}
/** /**
* Checks if current user can access current ContentContainer by using * Checks if current user can access current ContentContainer by using
* underlying behavior ProfileControllerBehavior/SpaceControllerBehavior. * underlying behavior ProfileControllerBehavior/SpaceControllerBehavior.