Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function validate_login($from = "")
- {
- if ($this->crud_model->check_recaptcha() == false && get_frontend_settings('recaptcha_status') == true) {
- $this->session->set_flashdata('error_message', get_phrase('recaptcha_verification_failed'));
- redirect(site_url('home/login'), 'refresh');
- }
- $email = $this->input->post('email');
- $password = $this->input->post('password');
- $credential = array('email' => $email, 'password' => sha1($password), 'status' => 1);
- // Checking login credential for admin
- $query = $this->db->get_where('users', $credential);
- if ($query->num_rows() > 0) {
- $row = $query->row();
- $this->session->set_userdata('user_id', $row->id);
- $this->session->set_userdata('role_id', $row->role_id);
- $this->session->set_userdata('role', get_user_role('user_role', $row->id));
- $this->session->set_userdata('name', $row->first_name . ' ' . $row->last_name);
- $this->session->set_userdata('is_instructor', $row->is_instructor);
- $this->session->set_flashdata('flash_message', get_phrase('welcome') . ' ' . $row->first_name . ' ' . $row->last_name);
- if ($row->role_id == 1) {
- if ($this->input->post('rememberme')){
- set_cookie("email",$email, 2 * 60);
- set_cookie("password",$password, 2 * 60);
- $this->session->set_userdata('admin_login', '1');
- redirect(site_url('admin/dashboard'), 'refresh');
- }else {
- $this->session->set_userdata('admin_login', '1');
- redirect(site_url('admin/dashboard'), 'refresh');
- }
- } else if ($row->role_id == 2) {
- if ($this->input->post('rememberme')){
- set_cookie("email",$email, 2 * 60);
- set_cookie("password",$password, 2 * 60);
- $this->session->set_userdata('user_login', '1');
- if($this->session->userdata('url_history')){
- redirect($this->session->userdata('url_history'), 'refresh');
- }
- redirect(site_url('home'), 'refresh');
- }else{
- $this->session->set_userdata('user_login', '1');
- if($this->session->userdata('url_history')){
- redirect($this->session->userdata('url_history'), 'refresh');
- }
- redirect(site_url('home'), 'refresh');
- }
- }
- } else {
- $this->session->set_flashdata('error_message', get_phrase('invalid_login_credentials'));
- redirect(site_url('home/login'), 'refresh');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement