Created
February 10, 2021 03:55
-
-
Save aasumitro/710c7f63832abff8efb5ff3c0932912f to your computer and use it in GitHub Desktop.
CI3 Api LoginController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class LoginController extends CI_Controller | |
{ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->load->library('api/AuthenticatesUsers', NULL, 'auth'); | |
$this->load->helper('api_response'); | |
} | |
public function index() | |
{ | |
$authenticate = $this->auth; | |
if ($authenticate->login()) { | |
response_with_json( | |
200, | |
'ok', | |
$authenticate->getSuccessRespond(), | |
'data' | |
); | |
return; | |
} | |
response_with_json( | |
400, | |
'bad request', | |
$authenticate->getFailedRespond(), | |
'error' | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment