[eluser]doubleplusgood[/eluser]
Hi there,
I have a working login form for my site. But I need to expand on this so that different user types are redirected to different pages. Currently, when everyone logs in, they are redirected to account/vehicle_list. But I now want all users who have 'isPublic' in their db record to be redirected to account/vehicle_publiclist and all users with 'isDealer' redirected to account/vehicle_list.
My account controller has the following functions;
Code:
public function index()
{
$view_data = array();
if ( $this->auth->logged_in() )
{
redirect('account/vehicle_list');
}
else
{
$view_data['title1'] = "Log in, or join in...";
$view_data['title2'] = "it's up to you";
$view_data['body'] = "login";
$view_data['regions'] = $this->dealers->getRegions();
$view_data['view_file'] = 'account/index';
}
$this->load->view('layout', $view_data);
}
public function login()
{
$email = $this->input->post('email');
$password = $this->input->post('password');
if ( empty($email) || empty($password) )
{
die('fill it in!');
}
$logged_in = $this->auth->login($email, $password);
redirect('account');
}
And my Auth library has;
Code:
function login($email, $password)
{
$this->_obj->db->where('email', $email);
$query = $this->_obj->db->get('users', 1);
if ( $query->num_rows() == 0 )
{
return FALSE;
}
$user = $query->row_array();
$hashed = $this->_hash($password, $email, $user['salt']);
if ( $user['password'] === $hashed['hashed'] )
{
$this->_set_session($user);
return TRUE;
}
return FALSE;
}
So, I'm wondering if someone might be able to help me figure out how to redirect users based on the isDealer or isPublic being set in their db record?
Thanks,
Neil