Esempio n. 1
0
 /**
  * Construct the (base) controller. This happens when a real controller is constructed, like in
  * the constructor of IndexController when it says: parent::__construct();
  */
 function __construct(LoggerInterface $logger = null)
 {
     // always initialize a session
     Session::init();
     // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
     if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
         header('location: ' . Config::get('URL') . 'login/loginWithCookie');
     }
     // create a view object to be able to use it inside a controller, like $this->View->render();
     $this->View = new View();
     //initialize the logger object
     $this->logger = $logger;
 }
Esempio n. 2
0
 /**
  * Login with cookie
  */
 public function loginWithCookie()
 {
     // run the loginWithCookie() method in the login-model, put the result in $login_successful (true or false)
     $login_successful = LoginModel::loginWithCookie(Request::cookie('remember_me'));
     // if login successful, redirect to dashboard/index ...
     if ($login_successful) {
         Redirect::to('index/index');
     } else {
         // if not, delete cookie (outdated? attack?) and route user to login form to prevent infinite login loops
         LoginModel::deleteCookie();
         Redirect::to('login/index');
     }
 }