public function resetpassword($param) { $slug = $param[0]; $hash = new \models\hash(); $user = new User(); $this->data['title'] = 'Reset Password'; $row = $hash->get_row(array('hash' => $slug)); if ($row->status == 'active') { $user_id = $row->user_id; $this->data['userDetails'] = $user->find($user_id); if (isset($_POST) && !empty($_POST)) { $user_details = $user->get_row(array('email' => $_POST['email'])); if ($_POST['password'] == $_POST['password2']) { //UPDATE USER PASSWORD $user->update(array("password" => md5($_POST['password'])), array("id" => $user_id)); $this->data['success'] = "Password reset successful!."; } else { $this->data['error'] = 'This email does not exist in our records!'; } } } else { $this->data['error'] = 'Reset record not found!'; } View::rendertemplate('header', $this->data); View::render('account/resetpassword', $this->data); View::rendertemplate('footer', $this->data); }
public function forgotpassword() { $this->data['title'] = 'Retrieve Password'; $hash_model = new \models\hash(); if (isset($_POST['email']) && !empty($_POST['email'])) { $user_details = $this->user_model->getColRow('user_email', $_POST['email']); if ($user_details->user_email != '') { $get_status = $this->status_model->getColRow('status_title', 'active'); $uniqid = uniqid(); $insert = $hash_model->create(array('hash_user_id' => $user_details->user_id, 'hash_value' => $uniqid, 'hash_status_id' => $get_status->status_id)); //SEND ACCOUNT DETAILS TO USER $fullname = $user_details->user_firstname . ' ' . $user_details->user_lastname; $subject = 'Reset Password'; $content .= "You have requested for a new password, please click the link below to reset"; $content .= '<a href="' . DIR . 'account/resetpassword/' . $uniqid . '" target="_blank">Get Password </a>'; $mail = new \helpers\phpmailer\mail(); $mail->general($user_details->user_email, $subject, $fullname, $content); $this->data['success'] = "Congrats!, A reset link has been sent to your email"; } else { $this->data['error'] = 'This email does not exist in our records!'; } } View::rendertemplate('header', $this->data); View::render('account/forgotpassword', $this->data); View::rendertemplate('footer', $this->data); }