D
D
dk-web2015-10-10 15:56:33
PHP
dk-web, 2015-10-10 15:56:33

Where to raise the authorization of an MVC project?

First of all, I want to say thanks to Toaster and some stubborn users who answered half of my questions for several months - see frameworks.
I chose two for myself ... Yii2 and Laravel. Zend and Symfony have turned out to be heavy so far.
But the ultimate goal of my bike is to finish my offspring-monster.
Actually the question... With the help of some magic and one British hello-tubers, I made the admin authorization not through two lines in htaccess, but with the help of autoloaders and dozens of two classes... Well, okay - it will do... I made a mistake
in one thing - I I tested and wrote everything in the main controller. Now the task is to raise it up.

public function index()
  {
    if(Session::exists('success')){
        echo Session::flash('success');
    }
  $user = new User();
    if($user->isLoggedIn()){
        $this->view->assign('user',$user);
        echo $this->view->render('index');
    }
    else{
         echo $this->view->render('login');
    }
  }

This is the code from the main controller.
If you raise it in app.php - the main initializing file, then there is still no view to do render ... if you do redirect, then I get some kind of cyclic redirect..
/reg/public/admin/
/reg/public/admin /module1
, that is, when accessing any link, the session and cookies were first checked and, if authorized, then it got to the required page, and if not, then to the login form
. sorry - I don’t always know how to ask briefly-)
UPD: did I ask something stupid (stupid)? ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question