<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller {
    private $isLoggedIn;
    function __construct(){
        parent::__construct();
        $this->load->model('auth_model', 'auth_m');
        $this->isLoggedIn = $this->session->userdata('is_logged_in');
    }

    function index(){
        if($this->isLoggedIn){
            redirect('home');
        }
        $this->load->view('login_form');
    }

    function doLoginJson(){
        $params   = $this->input->post();
        $response = $this->auth_m->doLogin($params);
        echo json_encode($response);
    }
}
