This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jarv.aleksei53794
jarv.aleksei53794

I have developed a website with the OctoberCMS:

http://beonmind.ru

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.

How can I fix this?

before: http://prntscr.com/sr59am login: http://prntscr.com/sr5bb2 after: http://prntscr.com/sr5akj

Last updated

JeffGoldblum
JeffGoldblum

That depends entirely on what code is actually on that page. Something is probably checking to see if the backend user is authenticated and failing.

jarv.aleksei53794
jarv.aleksei53794

This happens due to this check

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.

Last updated

JeffGoldblum
JeffGoldblum

That doesn't seem like the problem, I don't think returning null from onStart even does anything in the first place.

jarv.aleksei53794
jarv.aleksei53794

LukeTowers said:

That doesn't seem like the problem, I don't think returning null from onStart even does anything in the first place.

What do you think might be the problem that it return 404 page?

JeffGoldblum
JeffGoldblum

I would have to see all of the page code you're using and the code for any components onRun methods being used on the page

jarv.aleksei53794
jarv.aleksei53794

where can I send you the code?

JeffGoldblum
JeffGoldblum

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.

jarv.aleksei53794
jarv.aleksei53794

for example, this page won't load without administrator's authentication

title = "Beonmind"
url = "/communities"
layout = "wrapper"
description = "Communities page."
is_hidden = 1

[Communities]
slug = "{{ :slug }}"
categoryPage = "blog/category"

[NewCommunity]
==
<!-- Header -->
{% partial 'communities_header' %}

<!-- Content -->
{% partial 'communities_content' %}

and here is the component

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;
    }

Last updated

jarv.aleksei53794
jarv.aleksei53794

Maybe those pages are considered as "backend" pages

JeffGoldblum
JeffGoldblum

What's in the NewCommunity component?

JeffGoldblum
JeffGoldblum

admin_auth is the cookie used for backend authentication, those pages are still frontend pages. The cookie will be present any time you are logged in.

jarv.aleksei53794
jarv.aleksei53794
<?php namespace rainlab\blog\components;

use Cms\Classes\ComponentBase;
use Auth;
use Input;
use Validator;
use ValidationException;
use Redirect;
use Response;
use Flash;
use Db;
use Carbon\Carbon;
use Cms\Classes\Page;
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;

class NewCommunity extends ComponentBase {

    public function componentDetails(){
        return [
            'name' => 'New Community',
            'description' => 'Create New Community Form'
        ];
    }

    public function onCommunitySave(){

      if(!Auth::getUser()){
        return;
      }

      if(!Input::get('title')){
        throw new ApplicationException('Введите название сообщества!');
      }

      $rules = [
                'title'    => 'required|between:3,255',
            ];

      $data = [
        'title'    => Input::get('title'),
      ];
      $validation = Validator::make($data, $rules);
      if ($validation->fails()) {
        throw new ValidationException($validation);
      }

      $community = new Community();
      # get the current time in the proper format for a sql timestamp field
      $timestamp = date('Y-m-d H:i:s');

      $slug = str_replace(' ', '-', Input::get('title'));
      $user = Auth::getUser();

      $community->creator_id = $user->id;
      $community->main_photo = '/themes/responsiv-flat/assets/images/default-profile.jpg';
      $community->title = $this->makeCensor(Input::get('title'));
      $community->slug = $slug;

      if(Input::get('theme')){
        $community->theme = Input::get('theme');
      }

      if(Input::get('type')){
        $community->type = Input::get('type');
      }

      if(Input::get('subtitle')){
        $community->subtitle = $this->makeCensor(Input::get('subtitle'));
      }

      if(Input::get('description')){
        $community->description = $this->makeCensor(Input::get('description'));
      }

      if($community->created_at == null){
        $community->created_at = $timestamp;
      }

      $community->save();

      $settings = new CommunitySettings();
      $settings->community_id = $community->id;
      $settings->save();

      $participant = new CommunityParticipants();
      $participant->user_id = $user->id;
      $participant->community_id = $community->id;
      $participant->save();

      $owners = new CommunityOwners();
      $owners->user_id = $user->id;
      $owners->community_id = $community->id;
      $owners->save();

      $post = new BlogPost();
      $post->user_id = $user->id;
      $post->isForeword = true;
      $post->published = 0;
      $post->title = 'Предисловие';
      $post->content = 'Предисловие';
      $post->post_type = 'community';
      $post->community_id = $community->id;
      $post->slug = 'foreword-' . $community->id;
      $post->save();

      if($community->save()){
        return Redirect::to('/community/'. $slug . '/settings');
      }

  }

  public function makeCensor($string = null){
    $badWords = array(
             'сучара' => '***',
             'хуйня' => '***',
             'блят' => '***',
             'бляд' => '***',
             'пидарас' => '***',
             'ипись ' => '***',
             'изъеб' => '***',
             'еблан' => '***',
             'ебеный' => '***',
             'ебущий' => '***',
             'ебанашка' => '***',
             'ебырь' => '***',
             'хуище' => '***',
             'гребан' => '***',
             'уебище' => '***',
             'уебан' => '***',
             'феееб' => '***',
             '6ляд' => '***',
             'сцука' => '***',
             'ебали' => '***',
             'пестато' => '***',
             'ебало' => '***',
             'ебли' => '***',
             'ебло' => '***',
             'ебанут' => '***',
             'ебут' => '***',
             'заебу' => '***',
             'выебу' => '***',
             'хуйло' => '***',
             'нехе' => '***',
             'неху' => '***',
             'ниху' => '***',
             'нихе' => '***',
             'ибанут' => '***',
             'fuck' => '***',
             'хули' => '***',
             'хуля' => '***',
             'хуе' => '***',
             'хуё' => '***',
             'мудл' => '***',
             'хер ' => '***',
             'пидар' => '***',
             'наху' => '***',
             'педер' => '***',
             'пидер' => '***',
             'пидир' => '***',
             'ёбну' => '***',
             'ебну' => '***',
             'ебыр' => '***',
             'заеб' => '***',
             'заёб' => '***',
             'ебен' => '***',
             'блятc' => '***',
             'ебли' => '***',
             'аебли' => '***',
             'ебло' => '***',
             'заебло' => '***',
             'переебло' => '***',
             'отебло' => '***',
             'отъебло' => '***',
             'отьебло' => '***',
             'ебеш' => '***',
             'выеб' => '***',
             'отъеб' => '***',
             'отьеб' => '***',
             'перееб' => '***',
             'хуйла' => '***',
             'заеб' => '***',
             'хую' => '***',
             'иннах' => '***',
             '6ля' => '***',
             '6ля' => '***',
             'блЯ' => '***',
             'бля' => '***',
             'бля' => '***',
             'хуило' => '***',
             'хуюше' => '***',
             'сука' => '***',
             'ъеб' => '***',
             'ъёб' => '***',
             'бляд' => '***',
             'блябу' => '***',
             'бля бу' => '***',
             'залупа' => '***',
             'хера' => '***',
             'пизжен' => '***',
             'ёпта' => '***',
             'епта' => '***',
             'пистапол' => '***',
             'пизда' => '***',
             'залупить' => '***',
             'ебать' => '***',
             'мудо' => '***',
             'манда ' => '***',
             'мандавошка' => '***',
             'мокрощелка' => '***',
             'муда' => '***',
             'муде' => '***',
             'муди' => '***',
             'мудн' => '***',
             'мудо' => '***',
             'пизд' => '***',
             'хуе' => '***',
             'похую' => '***',
             'похуй' => '***',
             'охуи' => '***',
             'ебля' => '***',
             'пидорас' => '***',
             'пидор' => '***',
             'херн' => '***',
             'щлюха' => '***',
             'хуй' => '***',
             'нах ' => '***',
             'писдеш' => '***',
             'писдит' => '***',
             'писдиш' => '***',
             'нехуй' => '***',
             'ниибаца' => '***'
              );
    $censored = strtr($string, $badWords); // This is a *** sentence
    return $censored;
  }

   public function onCommunityDelete(){

        $community_id = Input::get('community_id');
        $community = Community::find($community_id);

        if(Auth::getUser()){
        $user = Auth::getUser();
        } else {
          return;
        }
        if($community->creator_id == $user->id){
          $community->delete();
          return Redirect::to('/');
        };
        //return Redirect::to('/post/'. $slug);
   }

   public function onCommunityUpdate(){

      if(!Auth::getUser()){
        return;
      }

      $community_id = Input::get('community_id');
      $community = Community::find($community_id);

      # get the current time in the proper format for a sql timestamp field
      $timestamp = date('Y-m-d H:i:s');

      $user = Auth::getUser();

      if(Input::get('main_photo')){
          $community->main_photo = Input::get('main_photo');
      }

      $badWords = array(
             'сучара' => '***',
             'хуйня' => '***',
             'блят' => '***',
             'бляд' => '***',
             'пидарас' => '***',
             'ипись ' => '***',
             'изъеб' => '***',
             'еблан' => '***',
             'ебеный' => '***',
             'ебущий' => '***',
             'ебанашка' => '***',
             'ебырь' => '***',
             'хуище' => '***',
             'гребан' => '***',
             'уебище' => '***',
             'уебан' => '***',
             'феееб' => '***',
             '6ляд' => '***',
             'сцука' => '***',
             'ебали' => '***',
             'пестато' => '***',
             'ебало' => '***',
             'ебли' => '***',
             'ебло' => '***',
             'ебанут' => '***',
             'ебут' => '***',
             'заебу' => '***',
             'выебу' => '***',
             'хуйло' => '***',
             'нехе' => '***',
             'неху' => '***',
             'ниху' => '***',
             'нихе' => '***',
             'ибанут' => '***',
             'fuck' => '***',
             'хули' => '***',
             'хуля' => '***',
             'хуе' => '***',
             'хуё' => '***',
             'мудл' => '***',
             'хер ' => '***',
             'пидар' => '***',
             'наху' => '***',
             'педер' => '***',
             'пидер' => '***',
             'пидир' => '***',
             'ёбну' => '***',
             'ебну' => '***',
             'ебыр' => '***',
             'заеб' => '***',
             'заёб' => '***',
             'ебен' => '***',
             'блятc' => '***',
             'ебли' => '***',
             'аебли' => '***',
             'ебло' => '***',
             'заебло' => '***',
             'переебло' => '***',
             'отебло' => '***',
             'отъебло' => '***',
             'отьебло' => '***',
             'ебеш' => '***',
             'выеб' => '***',
             'отъеб' => '***',
             'отьеб' => '***',
             'перееб' => '***',
             'хуйла' => '***',
             'заеб' => '***',
             'хую' => '***',
             'иннах' => '***',
             '6ля' => '***',
             '6ля' => '***',
             'блЯ' => '***',
             'бля' => '***',
             'бля' => '***',
             'хуило' => '***',
             'хуюше' => '***',
             'сука' => '***',
             'ъеб' => '***',
             'ъёб' => '***',
             'бляд' => '***',
             'блябу' => '***',
             'бля бу' => '***',
             'залупа' => '***',
             'хера' => '***',
             'пизжен' => '***',
             'ёпта' => '***',
             'епта' => '***',
             'пистапол' => '***',
             'пизда' => '***',
             'залупить' => '***',
             'ебать' => '***',
             'мудо' => '***',
             'манда ' => '***',
             'мандавошка' => '***',
             'мокрощелка' => '***',
             'муда' => '***',
             'муде' => '***',
             'муди' => '***',
             'мудн' => '***',
             'мудо' => '***',
             'пизд' => '***',
             'хуе' => '***',
             'похую' => '***',
             'похуй' => '***',
             'охуи' => '***',
             'ебля' => '***',
             'пидорас' => '***',
             'пидор' => '***',
             'херн' => '***',
             'щлюха' => '***',
             'хуй' => '***',
             'нах ' => '***',
             'писдеш' => '***',
             'писдит' => '***',
             'писдиш' => '***',
             'нехуй' => '***',
             'ниибаца' => '***'
              );

      if(Input::get('title')){
        $slug = str_replace(' ', '-', Input::get('title'));
        $community->title = strtr(Input::get('title'), $badWords); // This is a *** sentence
      }
      if(Input::get('subtitle')){
        $community->subtitle = strtr(Input::get('subtitle'), $badWords); // This is a *** sentence
      }
      if(Input::get('description')){
        $community->description = strtr(Input::get('description'), $badWords); // This is a *** sentence
      }

      $community->updated_at = $timestamp;

      $community->save();

        if($community->save()){
          return Redirect::to('/community/'. $slug , '/settings');
        }
    }
}

Last updated

JeffGoldblum
JeffGoldblum

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.

jarv.aleksei53794
jarv.aleksei53794

It is all fixed now

The pages were set to "hidden"

http://prntscr.com/ss2ync

JeffGoldblum
JeffGoldblum

That would make sense yes :) I rarely use that feature so it didn't even occur to me

Eoler
Eoler

jarv.aleksei53794 said: for example, this page won't load without administrator's authentication

title = "Beonmind"
url = "/communities"
layout = "wrapper"
description = "Communities page."
**is_hidden = 1**

Which is expected if you set the page as hidden in CMS (read the help block under the "Hidden" checkbox).

JeffGoldblum
JeffGoldblum

Yes, he realized that.

1-18 of 18

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.