/** * Action Login * */ public static function login() { # if user was login before if (Request::is_authenticated()) { # redirect to main page Response::redirect(''); } # if request path contain ?next=page if (Request::GET()->next) { if (Session::flash()->has('next')) { Session::pop('next'); } # push next request page in the session Session::push('next', Request::GET()->next); } if ("POST" == Request::method()) { $username = Request::POST()->username; # $_POST['username'] $password = Request::POST()->password; # auth by base controller $auth = self::auth($username, $password); if ($auth) { # if session path contain next request page if (Session::flash()->has('next')) { # redirect to that request page Response::redirect(Session::pop('next')); } else { # Response::redirect(''); } } else { # if authenticated failure # pust a flash message Session::push('flash-message', 'Authenticated failure!'); View::render('login'); } } else { View::render('login'); } }