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

class Auth extends Api_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function login()
    {
        $email = $this->input->post('email');
        $password = $this->input->post('password');

        if (!isset($email, $password)) {
            $this->FailedResponse('Invalid Param');
        }

        $user = $this->getUserModel()->get_user($email, $password);
        if ($user) {
            $this->SuccessResponse($user);
        } else {
            $user = $this->getUserModel()->get_user($email, $password);
            if ($user) {
                $this->SuccessResponse($user);
            } else {
                $this->FailedResponse('You did not register yet');
            }
        }
    }
}