public function log_in() { $this->load->helper('cookie'); $this->load->helper('form'); $this->load->model('login_model'); $email = $this->input->post('email', TRUE); $post_password = $this->input->post('password', TRUE); $getPassword = $this->getPassword($email); $password = blow_me($post_password, $getPassword); $remember_me = $this->input->post('remember', TRUE); $login_attempt = $this->login_model->checkLoginData($email, $password); if ($login_attempt['success']) { if ($remember_me == 'true') { $cookie = array('name' => 'ltd-login', 'value' => json_encode(array('1I1T1TLI11II' => $email, 'I11T1TLI11IT' => $this->input->post('password', TRUE))), 'expire' => '2592000', 'secure' => FALSE, 'domain' => '.logthedog.com'); $this->input->set_cookie($cookie); } else { // delete remember cookie $cookie = array('name' => 'ltd-login', 'value' => '', 'expire' => '0', 'domain' => '.logthedog.com'); $rex = delete_cookie($cookie); } $dogs = $this->login_model->retrieveDogs($this->session->userdata('eMail')); if (count($dogs) > 0) { foreach ($dogs as $k) { $current_dog[] = (array) $this->login_model->fetchDog($k); } } if (isset($current_dog)) { $_SESSION['dogs'] = $current_dog; } } echo json_encode($login_attempt); }
public function user_reset() { $this->load->helper('validation'); $retArray = array('success' => false); $expired = false; $userID = $this->input->get('flirzel'); $password = $this->input->get('kwerp'); $this->load->model('account_model'); $creds = $this->account_model->retrieveTempPassword($userID); if ($creds['success']) { $m = '<div class="container"><div class="row-fluid text-center"><h3>'; $start_time = new DateTime($creds['exp']); $now = new DateTime(); $time_elapsed = $now->diff($start_time); // if it's more than an hour old, it's considered expired. if ($time_elapsed->h > 0) { if ($time_elapsed->h > 1 || $time_elapsed->m > 0 || $time_elapsed->s > 0) { $expired = true; } } if (!$expired) { // encrypt the password from query string, compare it to pre-crypted password $compare_this = blow_me($password, $creds['password']); if ($compare_this === $creds['password']) { $retArray['success'] = true; $retArray['id'] = $userID; $retArray['email'] = $creds['email']; $retArray['username'] = $creds['username']; $m .= 'Please choose a new password:'******'Your temporary password is incorrect.'; $m .= ' You may try the "Forgot your password?" option on '; $m .= 'the home page again.'; } } else { $m = 'Sorry, your temporary password has expired.'; } } $retArray['message'] = $m . '</h3></div></div>'; $this->load->view('password_reset', $retArray); $this->load->view('error_modal'); }