However, if the users that access the website are not logged in to the backend panel, they can't navigate to most of the pages. They receive a 404 page.
If you access the back-end panel, then everything works just fine.
function onStart () {
if (!Auth::getUser()) {
return;
}
}
However, I am trying to check if the user is authenticated using the Rainlab User plugin. But it checks if the backend user is authenticated?
The users are registered on the website with the Rainlab User plugin.
If you don't want to paste it here then I don't really have the time to review it through any other platform unless you want to pay for premium support. If you post it here in code blocks then I'll review it when I have time. Anything else requires too much time for me to receive, process, review, and then respond.
use Request;
use Auth;
use Input;
use Validator;
use ValidationException;
use Redirect;
use Response;
use Db;
use ApplicationException;
use RainLab\Blog\Classes\LogsActivity as Activity;
use Carbon\Carbon;
use Cms\Classes\Page;
use Cms\Classes\ComponentBase;
use RainLab\Blog\Models\Post as BlogPost;
use RainLab\Blog\Models\Community as Community;
use RainLab\Blog\Models\CommunitySubscribers as CommunitySubscribers;
use RainLab\Blog\Models\CommunityOwners as CommunityOwners;
use RainLab\Blog\Models\CommunityParticipants as CommunityParticipants;
use RainLab\Blog\Models\CommunityModerators as CommunityModerators;
use RainLab\Blog\Models\CommunitySettings as CommunitySettings;
use RainLab\User\Models\User as User;
use RainLab\User\Models\BlockedUsers as BlockedUsers;
use rainlab\blog\models\Comments as CommentsModel;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use modules\system\helpers\DateTime;
use Beon\Blog\Models\Notification as Notification;
use Beon\Blog\Models\CommunityRequest as CommunityRequest;
use Beon\Blog\Models\CommunityModSettings as CommunityModSettings;
class Communities extends ComponentBase
{
/**
* @var RainLab\Blog\Models\Diary The post model used for display.
*/
public $communities;
/**
* @var RainLab\Blog\Models\Post The post model used for display.
*/
public $slug;
public function componentDetails()
{
return [
'name' => 'Communities',
'description' => 'List of All Communities'
];
}
public function defineProperties()
{
return [
'slug' => [
'title' => 'rainlab.blog::lang.settings.post_slug',
'description' => 'rainlab.blog::lang.settings.post_slug_description',
'default' => '{{ :slug }}',
'type' => 'string',
],
'categoryPage' => [
'title' => 'rainlab.blog::lang.settings.post_category',
'description' => 'rainlab.blog::lang.settings.post_category_description',
'type' => 'dropdown',
'default' => 'blog/category',
],
];
}
public function getCategoryPageOptions()
{
return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName');
}
public function onRun()
{
if($this->controller->param('theme')){
$this->communities = $this->page['communities'] = $this->getNewCommunities($this->controller->param('theme'));
} else {
$this->communities = $this->page['communities'] = $this->getNewCommunities();
}
if($this->controller->param('theme')){
$this->participant = $this->page['popular_communities'] = $this->getPopularCommunities($this->controller->param('theme'));
} else {
$this->participant = $this->page['popular_communities'] = $this->getPopularCommunities();
}
$this->popular = $this->page['participant_communities'] = $this->getParticipantCommunities();
$this->mycommunities = $this->page['my_communities'] = $this->getMyCommunities($this->controller->param('theme'));
$this->subscribed = $this->page['subscribed_communities'] = $this->getSubscribedCommunities($this->controller->param('theme'));
}
public function getNewCommunities($theme = null)
{
$communities = Community::whereNull('deleted_at')->orderBy('created_at', 'desc')->get();
if (!is_null($theme)) {
$communities = Community::whereNull('deleted_at')->where('theme', $theme)->orderBy('created_at')->get();
}
return $communities;
}
Also delete those screenshots please, anyone could easily manually type out your admin_auth and session cookies and then have full admin access to your account.