function authentication_user($password) { try { log_message('debug', "AUTHENTICATION"); $this->load->model('dto/DtoUser'); $this->load->model('dao/DaoUser'); $user = new DtoUser(); $userDao = new DaoUser(); $user->setUsername($this->input->post('username', TRUE)); $user->setPassword(md5($this->input->post('password', TRUE))); $result = $userDao->login($user); if ($result) { foreach ($result as $row) { $user->setUsername($row->username); $user->setUserid($row->userid); $user->setUsertype($row->usertype); $this->session->set_userdata('logged_in', $user); $this->session->set_userdata('username', $this->encryption->encrypt($user->getUsername())); $this->session->set_userdata('userid', $this->encryption->encrypt($user->getUserid())); $this->session->set_userdata('usertype', $user->getUsertype()); return TRUE; } } else { $this->form_validation->set_message('authentication_user', 'Invalid username or password. Please try again.'); return false; } } catch (Exception $ex) { log_message('debug', $ex->getMessage()); } }
public function authenticate() { log_message('debug', "AUTHENTICATION"); $this->load->model('dto/DtoUser'); $this->load->model('dao/DaoUser'); $user = new DtoUser(); $userDao = new DaoUser(); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); if ($this->form_validation->run() == FALSE) { log_message('debug', "FALSE"); $this->load->view('admin-kh4it/index', 'refresh'); } else { log_message('debug', "TRUE"); $user->setUsername($this->input->post('username')); $user->setPassword(md5($this->input->post('password'))); $result = $userDao->login($user); if ($result) { foreach ($result as $row) { log_message('debug', $row->username); log_message('debug', $row->userid); $user->setUsername($row->username); $user->setUserid($row->userid); $user->setUsertype($row->usertype); $this->session->set_userdata('logged_in', $user); $this->session->set_userdata('username', $this->encryption->encrypt($user->getUsername())); $this->session->set_userdata('userid', $this->encryption->encrypt($user->getUserid())); $this->session->set_userdata('usertype', $user->getUsertype()); log_message("debug", $this->encryption->decrypt($user->getUserid())); } redirect("admin/dashboard"); } else { $this->form_validation->set_message('check_database', 'Invalid username or password'); $this->login(); } } }
function login(DtoUser $user) { $this->db->select('id, name, usertype'); $this->db->from('dbsc_users_ci'); $this->db->where('username', $user->getUsername()); $this->db->where('password', $this->securityapi->encrypt($user->getPassword())); $this->db->where('block', 0); $this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 1) { return $query->result(); } else { return false; } }
function login(DtoUser $user) { $this->db->select('userid, username, usertype'); $this->db->from('USERS'); $this->db->where('username', $user->getUsername()); $this->db->where('password', $user->getPassword()); $this->db->where('active', 1); $this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 1) { return $query->result(); } else { return false; } }
public function updateUserStatusPro() { $this->load->model("dao/DaoUser"); $this->load->model("dto/DtoUser"); $user = new DtoUser(); $userDao = new DaoUser(); $user->setUserid($this->input->post('userid')); $user->setActive($this->input->post("status")); if ($userDao->update_status($user)) { $data["ERROR"] = false; } else { $data["ERROR"] = true; $data["ERR_MSG"] = "Your user cannot update."; } echo json_encode($data); }