Created
November 26, 2015 03:51
-
-
Save zukilover/6920f2868318828cad7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function reset_password($key = NULL) | |
{ | |
if($key) | |
{ | |
$row = $this->model_reset_password->get_reset_password($key); | |
if($row) | |
{ | |
$today = date('Y-m-d H:i:s'); | |
$expired = $row->date_created; | |
$hourdiff = round((strtotime($today) - strtotime($expired)) / 3600, 1); | |
if ($hourdiff >= 24) | |
{ | |
$data['message'] = 'The deadline has expired'; | |
} | |
else | |
{ | |
$random_password = substr(md5(time()), 0,6); | |
$user = $this->model_skeddoer->get_single('users', 'user_email', $row->email); | |
$data_email = array( | |
'email_content' => "Succeeded in resetting your password, please login to your account with <br> Username : ".$user->user_name ."<br> password : ".$random_password, | |
'email_cta_url' => site_url('skeddoer/login/'), | |
'email_cta_text' => 'Login' | |
); | |
$message = $this->load->view('public/email_template', $data_email, TRUE); | |
$mail = array( | |
'to' => $row->email, | |
'subject' => 'Success Reset Password', | |
'message' => $message, | |
'module' => 'member reset password', | |
'from' => SKEDDO_MAIL | |
); | |
$idmailer = $this->lib_mailer->save($mail); | |
$this->lib_mailer->send_mail($idmailer); | |
$data_user = array( | |
"user_password" => enkripsi($random_password) | |
); | |
$result = $this->model_skeddoer->update_byemail($row->email, $data_user); | |
$result = $this->model_reset_password->change($row->idreset_password, array("status" => "done")); | |
if($result) | |
{ | |
$data['message'] = 'Successfully Reset Password, the password will be immediately sent to your email'; | |
} | |
else | |
{ | |
$data['message'] = 'Error reset password'; | |
} | |
} | |
} | |
else | |
{ | |
$data['message'] = 'Invalid password reset link'; | |
} | |
} | |
else | |
{ | |
$data['message'] = 'Key Kosong'; | |
} | |
$data['title'] = 'Reset Password'; | |
$this->template->render('front/page/page_message', $data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment