apollodec/Apollo/api/application/controllers/Login_Controller.php
venbatechnologies@gmail.com e51ae24fb4 login page change
2019-02-08 17:04:47 +05:30

171 lines
6.0 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');
$accessFrom = $this->post('accessFrom');
$loginDetails = $this->login_model->login( $userMobile, $password, $accessFrom);// 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
}
}
/*
*Check Mobile Number*
*/
public function checkMobileNumber_post(){
$studentnum = $this->post('mobilenum');
$otpcheck = $this->post('otpcheck');
$password = $this->post('pwd');
$getstudent = $this->login_model->checkstudnetnumber($studentnum,$otpcheck,$password);
if ($getstudent)
{
$getstudent['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getstudent, 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
}
}
public function VerifyEmpOTP_post()
{
$EmpID = $this->post('EmpID');
$OTP = $this->post('OTP');
$Password = $this->post('Password');
$getstudent = $this->login_model->Emplogin($EmpID,$OTP,$Password);
if ($getstudent)
{
$getstudent['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getstudent, 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
}
}
}