Exemple #1
0
 public function auth()
 {
     $user = $this->input->post("uid", true);
     $pass = $this->input->post("pwd", true);
     $user = $user ? $user : "";
     $pass = $pass ? $pass : "";
     set_flash("uid", $user);
     set_flash("pass", $pass);
     if (empty($user)) {
         set_message("error", "User Name tidak boleh kosong!!");
         redirect("login");
     }
     if (empty($pass)) {
         set_message("error", "Password tidak boleh kosong!!");
         redirect("login");
     }
     /*
     if(empty($cap)):
     	set_message("error","Isi captcha sesuai dengan gambar!!");
     	redirect("login");
     endif;
     */
     /*
     $code=$_SESSION["captcha"]["code"];
     if(strtolower($code)!=strtolower($cap)):
     	set_message("error","Isi captcha sesuai dengan gambar!!");
     	redirect("login");
     endif;
     */
     //$password = $this->ion_auth_model->hash_password($this->input->post('pwd'));
     $ret = $this->lauth->login($user, b64encode($pass));
     // $ret=$this->login_model->check_login($user,$pass);
     if ($ret) {
         // echo "asd";exit;
         session_regenerate_id();
         $userSess = $_SESSION[$this->lauth->appname]["userdata"]["user"];
         // pre($userSess);exit;
         //$_SESSION[$this->lauth->appname]["groupdata"]=$this->conn->GetRow("select * from b_tb_group where idx=".$_SESSION[$this->lauth->appname]["userdata"]["user"]["group_id"]);
         //$_SESSION[$this->lauth->appname]["leveldata"]=$this->conn->GetRow("select * from tb_user_level where kd_level=".$userSess["user_level_id"]);
     }
     if (!$this->lauth->logged_in()) {
         redirect("login");
     } else {
         redirect("admin/dashboard");
     }
 }
Exemple #2
0
function gen_salt($length = 16, $urlsafe = false)
{
    $iv = mcrypt_create_iv(ceil(0.75 * $length), MCRYPT_DEV_URANDOM);
    return $urlsafe ? urlsafe_b64encode($iv) : b64encode($iv);
}
 function user_edit_save($id)
 {
     //debug();
     $id = $this->uri->segment(4);
     // $user = $this->ion_auth->user($id)->row();
     // $groups=$this->ion_auth->groups()->result_array();
     // $currentGroups = $this->ion_auth->get_users_groups($id)->result();
     $add_data = array('username' => $this->input->post('username'), 'first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'email' => $this->input->post('email'), 'company' => $this->input->post('company'), 'nomor_induk' => $this->input->post('nomor_induk'), 'phone' => $this->input->post('phone'), 'id' => $id, 'group_brwa' => $this->input->post("groups"), 'id_propinsi' => $this->input->post('id_propinsi'));
     //Update the groups user belongs to
     // $groupData = $this->input->post('groups');
     // if (isset($groupData) && !empty($groupData)) {
     // $this->ion_auth->remove_from_group('', $id);
     // foreach ($groupData as $grp) {
     // $this->ion_auth->add_to_group($grp, $id);
     // }
     // }
     //update the password if it was posted
     if ($this->input->post('password')) {
         $add_data['password'] = b64encode($this->input->post('password'));
     }
     $ok = $this->account_manager_model->users_update($add_data);
     redirect('admin/account_manager');
     // $ok=$this->ion_auth->update($user->id, $data);
     // if(!$this->input->is_ajax_request()):
     // return $ok;
     // else:
     // if($ok):
     // print "ok";
     // else:
     // print "not ok";
     // endif;
     // endif;
 }