Skip to content

Instantly share code, notes, and snippets.

@aasumitro
Created February 10, 2021 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aasumitro/710c7f63832abff8efb5ff3c0932912f to your computer and use it in GitHub Desktop.
Save aasumitro/710c7f63832abff8efb5ff3c0932912f to your computer and use it in GitHub Desktop.
CI3 Api LoginController
<?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