120 lines
4.3 KiB
PHP
Executable File
120 lines
4.3 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 Login_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['login_get']['limit'] = 500; // 500 requests per hour per user/key
|
|
$this->methods['login_post']['limit'] = 100; // 100 requests per hour per user/key
|
|
$this->methods['login_delete']['limit'] = 50; // 50 requests per hour per user/key
|
|
$this->load->model('Login_model', 'login_model');
|
|
$this->load->model('Announcement_model', 'announcement_model');
|
|
|
|
}
|
|
|
|
//This method used to get Login
|
|
|
|
public function login_post()
|
|
{
|
|
$userMobile = $this->post('userMobile');
|
|
$password = $this->post('password');
|
|
|
|
|
|
$loginDetails = $this->login_model->login( $userMobile, $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
|
|
}
|
|
}
|
|
|
|
// change old password
|
|
public function changePassword_post() {
|
|
$oldPassword = $this->post('oldPassword');
|
|
$newPassword = $this->post('newPassword');
|
|
$userId = $this->post('UserId');
|
|
// echo $oldPassword;
|
|
// echo $newPassword;
|
|
// echo $userId;
|
|
// exit();
|
|
$date = date('Y-m-d H:i:s');
|
|
$updateOn = $date;
|
|
$changePassword = $this->login_model->change_Password( $userId, $newPassword, $oldPassword, $updateOn);// Check if the users data store contains users (in case the database result returns NULL)
|
|
if ($changePassword)
|
|
{
|
|
$changePassword['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($changePassword, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'No record were found',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
|
}
|
|
}
|
|
|
|
/*
|
|
* get Announcement Details
|
|
* created by Surendiran
|
|
* */
|
|
public function getLoginAnnouncementDetails_post()
|
|
{
|
|
$requestedBy = $this->post('requestedBy');
|
|
|
|
|
|
$getAnnouncement = $this->announcement_model->getLoginAnnouncement();
|
|
|
|
if ($getAnnouncement)
|
|
{
|
|
$getAnnouncement['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getAnnouncement, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'No records found!',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|