function login() { $token = tokenGenerate(); $this->CI->m_security->filterPost('muser_' . $token, 'trim|required|min_length[1]'); $this->CI->m_security->filterPost('mpass_' . $token, 'trim|required|min_length[1]'); if ($this->CI->m_security->startPost() == TRUE) { $user = $this->CI->input->post('muser_' . $token, TRUE); $pass = $this->CI->input->post('mpass_' . $token, TRUE); $remember = $this->CI->input->post('mremember'); $rememberX = '0'; if ($remember) { $rememberX = '1'; } else { $rememberX = '0'; } $this->CI->load->library('auth/abstractauth'); $proses = $this->CI->abstractauth->loginDo($user, $pass, $rememberX); if ($proses == FALSE) { redirect(base_url(routeGet('login') . '?s=2'), 'refresh'); } else { runService('login', 'destroy'); $checkUser = array('username' => $user); $userid = $this->CI->m_database->fieldRow('userlogin', $checkUser, 'user_id'); $role = taxonomyRead($userid, 'role_user'); $this->createSessionLogin($user, $role, $rememberX); redirect(base_url() . roleDirectUser(), 'refresh'); } } else { redirect(base_url(routeGet('login') . '?s=1'), 'refresh'); } }
function loginDo($username, $password, $remember = '0') { $checkUsername = array('username' => $username); if ($this->CI->m_database->isBOF('userlogin', $checkUsername) == TRUE) { return false; } else { $dbpass = $this->CI->m_database->fieldRow('userlogin', $checkUsername, 'password'); $userid = $this->CI->m_database->fieldRow('userlogin', $checkUsername, 'user_id'); $valPass = $this->CI->m_security->validationPassword($password, $dbpass); if ($valPass == TRUE) { $tglSekarang = dateNow(TRUE); taxonomyCreate($userid, 'login_user', $tglSekarang); $service = runService('login', 'after'); if ($service == TRUE) { return true; } else { runService('login', 'before'); return false; } } else { runService('login', 'before'); return false; } } }
?> " placeholder="Username Anda"> </div> <div class="form-group"> <label class="sr-only">Password</label> <input type="password" name="<?php echo authForm('pass'); ?> " class="form-control" autocomplete="off" id="<?php echo authForm('pass', FALSE); ?> " placeholder="Password Anda"> </div> <p> <?php echo runService('login', 'before'); ?> </p> <div class="form-group"> <label class="sr-only"> </label> <div class="checkbox"> <label> <input type="checkbox" name="mremember"/>Ini adalah komputer pribadi saya </label> </div> </div> <p class="submit"> <input type="submit" name="minang-submit" id="minang-submit" class="btn" value="Log In" /> </p> <?php