FuelPHP Bin
Sign in
Public
PHP
Save
<?php public function action_login() { //$fieldset = Fieldset::instance('fastlogin'); $val = Validation::forge('fastlogin'); //$val = $fieldset->form(); if (Input::method() == 'POST') { $val->add('email', 'Email or Username') ->add_rule('required'); $val->add('password', 'Password') ->add_rule('required'); if ($val->run()) { $auth = Auth::instance(); // check the credentials. This assumes that you have the previous table created if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) { // credentials ok, go right in if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') { $current_user = Model\Auth_User::find_by_username(Auth::get_screen_name()); } else { $current_user = Model_User::find_by_username(Auth::get_screen_name()); } Session::set_flash('success', e('Welcome, '.$current_user->username)); Response::redirect('admin'); } else { $this->template->set_global('login_error', 'Fail'); } } } $view = View::forge('admin/login', array('val' => $val), false); $this->template->content = $view; }