101 lines
3.7 KiB
PHP
101 lines
3.7 KiB
PHP
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Complereset extends CI_Controller {
|
|
|
|
public function index() {
|
|
//echo "ameye kvkgkg";
|
|
$data['action_message'] = "";
|
|
$data["message"] = "Enter your new password to reset.<br> We will send you an email to confirm reset";
|
|
|
|
if ($_GET) {//this is first load of page
|
|
$data['passlink'] = $this->input->get('passlink');
|
|
if ($this->loadLinkData($data['passlink']) == false) {
|
|
redirect('/home'); // if link is not good - GET OUT
|
|
}
|
|
|
|
$this->load->view('users/view_external_header');
|
|
$this->load->view('users/view_cmppass', $data);
|
|
$this->load->view('users/view_external_footer');
|
|
} else {
|
|
|
|
if ($_POST) {
|
|
$message = "";
|
|
$data['pass_link'] = $this->input->post('passlink');
|
|
$data['passlink'] = $this->input->post('passlink');
|
|
$confirmnewpass = $this->input->post('confirmnewpass');
|
|
$newpass = $this->input->post('newpass');
|
|
|
|
if ($this->loadLinkData($data['pass_link']) == true) {
|
|
|
|
if ($newpass == $confirmnewpass && strlen($confirmnewpass) >= 8) {
|
|
// call backend now
|
|
$data['description'] = trim($this->input->post('description'));
|
|
$data['newpass'] = $newpass;
|
|
|
|
$outx = array();
|
|
$this->load->model('backend_model');
|
|
$data['action'] = WRENCHBOARD_ACCOUNT_SETPASSWD;
|
|
$outx['error'] = '';
|
|
if ($this->backend_model->wrenchboard_api($data, $outx) == PHP_API_OK) {
|
|
$message = "<div class=\"text-left\"><div class=\"alert alert-info no-border\">" . $outx["status"] . "</div></div>";
|
|
$message = $outx["status"];
|
|
} else {
|
|
$message = "<div class=\"text-left\"><div class=\"alert alert-info no-border\">" . $outx["status"] . "</div></div>";
|
|
$message = $outx["status"];
|
|
|
|
}
|
|
}
|
|
} else {
|
|
$message = "Password must be same and over eight characters in length.";
|
|
}
|
|
} else {
|
|
|
|
$message = "Invalid or expired password reset link. Please restart the process.";
|
|
}
|
|
|
|
$data['action_message'] = "<div class=\"text-left\"><div class=\"alert alert-info no-border\">" . $message . "</div></div>";
|
|
|
|
$this->load->view('users/view_external_header');
|
|
$this->load->view('users/view_cmppass', $data);
|
|
$this->load->view('users/view_external_footer');
|
|
}
|
|
}
|
|
|
|
private function loadLinkData($passlink) {
|
|
$ret = false;
|
|
|
|
$query = $this->db->get_where('password_reset', array('pass_link' => $passlink, 'status' => 0));
|
|
if ($query->num_rows() == 1) {
|
|
$ret = true;
|
|
} else {
|
|
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
var $actionMessage = '';
|
|
|
|
private function resetMemberPass($email) {
|
|
$this->actionMessage = '';
|
|
//$group_id = $group_id + 0; // just making sure it is number
|
|
|
|
|
|
$x['email'] = $email;
|
|
|
|
|
|
$x['action'] = WRENCHBOARD_ACCOUNT_RESETPASS;
|
|
$this->load->model('backend_model');
|
|
$out = array();
|
|
$res = $this->backend_model->wrenchboard_api($x, $out);
|
|
if ($res == PHP_CREATED_OK) {
|
|
$this->actionMessage = 'Group Created';
|
|
} else {
|
|
$this->actionMessage = 'Unable to create job group...';
|
|
}
|
|
return $this->actionMessage;
|
|
}
|
|
|
|
}
|