<?php
class Controller_Admin extends Controller_Base
{
public $template = 'admin/template';
public function before()
{
parent::before();
if (Request::active()->controller !== 'Controller_Admin' or ! in_array(Request::active()->action, array('login', 'logout')))
{
if (Auth::check())
{
$admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;
if ( ! Auth::member($admin_group_id))
{
Session::set_flash('error', e('You don\'t have access to the admin panel'));
Response::redirect('/');
}
}
else
{
Response::redirect('admin/login');
}
}
}
public function action_login()
{
// Already logged in
Auth::check() and Response::redirect('admin');
$val = Validation::forge();
if (Input::method() == 'POST')
{
$val->add('email', 'Email or Username')
->add_rule('required');
$val->add('password', 'Password')
->add_rule('required');
if ($val->run())
{
if ( ! Auth::check())
{
if (Auth::login(Input::post('email'), Input::post('password')))
{
// assign the user id that lasted updated this record
foreach (\Auth::verified() as $driver)
{
if (($id = $driver->get_user_id()) !== false)
{
// credentials ok, check access level
$user = Model\Auth_User::find($id[1]);
if ($user->group >= 80) {
//logged in! yay!
$current_user = $user;
Session::set_flash('success', e('Welcome, ' . $current_user->username));
Response::redirect('admin');
}
else {
$this->template->set_global('login_error', 'No access!');
break;
}
}
}
}
else
{
$this->template->set_global('login_error', 'Login failed!');
}
}
else
{
$this->template->set_global('login_error', 'Already logged in!');
}
}
}
$this->template->title = 'Login';
$this->template->subtitle = 'See all the things!';
$this->template->content = View::forge('admin/login', array('val' => $val), false);
}
/**
* The logout action.
*
* @access public
* @return void
*/
public function action_logout()
{
Auth::logout();
Response::redirect('admin');
}
/**
* The index action.
*
* @access public
* @return void
*/
public function action_index()
{
$this->template->title = 'Dashboard';
$this->template->subtitle = 'Recent Events and Quick Stats';
$this->template->content = View::forge('admin/dashboard');
}
}
/* End of file admin.php */
if (Auth::check())So you might have to debug that. Perhaps your groups are different, it does a check if the logged-in user is member of the administrator group on id, maybe your id values are different?
{
$admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;
if ( ! Auth::member($admin_group_id))
{
Session::set_flash('error', e('You don\'t have access to the admin panel'));
Response::redirect('/');
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!