if (Auth::check())
{
// only allow admin access, or login/logout
if ( ! Auth::member(100) and ! in_array(Request::active()->action, array('login', 'logout')))
{
// generate an access failure message
Session::set_flash('error', e('You don\'t have access to the admin panel'));
// and redirect back to the homepage
Response::redirect('/');
}
}
else
{
// not logged-in, login first
Response::redirect('admin/login');
}
class Controller_Admin extends Controller_Base
{
.......
public function before()
{
parent::before();
if (Auth::check())
{
// only allow admin access, or login/logout
if (!Auth::member(100) and !in_array(Request::active()->action, array('login', 'logout')))
{
//only admin can log in here
Auth::logout();
// generate an access failure message
Session::set_flash('login_error', e('You don\'t have access to the admin panel'));
// and redirect back to the homepage
Response::redirect('admin/login');
}
}
else
{
// not logged-in, login first
Response::redirect('admin/login');
}
}
public function action_login()
{
// Already logged in
Auth::check() and Response::redirect('admin');
$val = Validation::forge();
if (Input::method() == 'POST')
{
... same ...
}
//this login_error only exists when user has logged in but not an admin user
Session::get_flash('login_error') and $this->template->set_global('login_error', Session::get_flash('login_error'));
$this->template->title = 'Login';
$this->template->content = View::forge('admin/login', array('val' => $val), false);
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!