FuelPHP Bin
Sign in
Public
PHP
Save
<?php class Controller_Private_User extends \Controller_Private { public function before() { parent::before(); \Debug::dump(\Auth::check()); die; } public function action_login() { \Debug::dump(\Auth::check()); die; // already logged in? if (\Auth::check()) { // yes, so go back to the page the user came from, or the // application dashboard if no previous page can be detected #\Messages::info(__('login.already-logged-in')); \Session::set_flash('info', 'login.already-logged-in'); #\Response::redirect_back('admin/dashboard'); } // was the login form posted? if (\Input::method() == 'POST') { // check the credentials. if (\Auth::instance()->login(\Input::param('username'), \Input::param('password'))) { // did the user want to be remembered? if (\Input::param('remember', false)) { // create the remember-me cookie \Auth::remember_me(); } else { // delete the remember-me cookie if present \Auth::dont_remember_me(); } // logged in, go back to the page the user came from, or the // application dashboard if no previous page can be detected \Response::redirect_back('dashboard'); } else { // login failed, show an error message #\Messages::error(__('login.failure')); Session::set_flash('error', e(__('login.failure'))); } } \Debug::dump(\Auth::check()); die; // display the login page #return \View::forge('private/login'); $this->theme->set_partial('content', 'private/user/login'); } public function action_dashboard() { \Session::set_flash('info', 'Dashboard'); $this->theme->set_partial('content', 'private/dashboard'); } public function action_logout() { \Debug::dump(\Auth::check()); die; // remove the remember-me cookie, we logged-out on purpose \Auth::dont_remember_me(); // logout \Auth::logout(); // inform the user the logout was successful #\Messages::success(__('login.logged-out')); Session::set_flash('success', e(__('login.logged-out'))); // and go back to where you came from (or the application // homepage if no previous page can be determined) \Response::redirect_back(); } public function after($response) { $response = parent::after($response); return $response; } }