apollodec/Apollo/api/application/controllers/Forget_Controller.php
venbatechnologies@gmail.com d06b1c0cba status file
2017-12-07 11:31:25 +05:30

83 lines
2.7 KiB
PHP
Executable File

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require_once APPPATH . '/libraries/REST_Controller.php';
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author
* @license MIT
* @link
*/
class Forget_Controller extends REST_Controller {
function __construct()
{
// Construct the parent class
parent::__construct();
// Configure limits on our controller methods
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
$this->methods['forgetlogin_get']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['forgetlogin_post']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['forgetlogin_delete']['limit'] = 50; // 50 requests per hour per user/key
$this->load->model('Forgot_model', 'forgot_model');
}
public function forgetlogin_post()
{
//$userMobile = $this->post('userMobile');
$details['MobileNumber'] = $this->post('userMobile');
// $details['Password'] = $this->post('password');
function generateRandomString($length = 8) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$password= generateRandomString();
$details['Password'] = md5($password);
$loginDetails = $this->forgot_model->forget($details, $password);// Check if the users data store contains users (in case the database result returns NULL)
if ($loginDetails)
{
$loginDetails['status'] = REST_Controller::HTTP_OK;
//Set the response and exit
$this->response($loginDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No users were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
}