apollodec/Apollo/api/application/controllers/Login_Controller.php
saravanakumar_kandasami 7d72a0b91a updated code
2017-11-21 14:56:39 +05:30

64 lines
2.1 KiB
PHP

<?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 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
}
}
}