Better error handling when user is not logged in

This commit is contained in:
Lucas Bartholemy 2017-08-10 16:17:26 +02:00
parent 6b7e5ad7e9
commit 4db81eee83

View File

@ -74,6 +74,12 @@ class ContentContainerController extends Controller
]);
$this->subLayout = "@humhub/modules/space/views/space/_layout";
// Handle case, if a non-logged user tries to acccess a hidden space
// Redirect to Login instead of showing error
if ($this->contentContainer->visibility == Space::VISIBILITY_NONE && Yii::$app->user->isGuest) {
}
} elseif ($userGuid !== null) {
$this->contentContainer = User::findOne(['guid' => $userGuid]);
@ -92,12 +98,6 @@ class ContentContainerController extends Controller
throw new HttpException(500, Yii::t('base', 'Could not determine content container!'));
}
/**
* Auto check access rights to this container
*/
if ($this->contentContainer != null && $this->autoCheckContainerAccess) {
$this->checkContainerAccess();
}
if (!$this->checkModuleIsEnabled()) {
throw new HttpException(405, Yii::t('base', 'Module is not enabled on this content container!'));
@ -121,6 +121,11 @@ class ContentContainerController extends Controller
return false;
}
// Auto check access rights to this container
if ($this->contentContainer != null && $this->autoCheckContainerAccess) {
$this->checkContainerAccess();
}
if ($this->contentContainer instanceof Space && (Yii::$app->request->isPjax || !Yii::$app->request->isAjax)) {
$options = [
'guid' => $this->contentContainer->guid,