source: lliurex-jocomunico/trunk/fuentes/lliurex-jocomunico.install/var/lib/application/controllers/Login.php @ 5728

Last change on this file since 5728 was 5728, checked in by joamuran, 3 years ago

Added zero-installed and updated jocomunico

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1
2<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
4require APPPATH . '/libraries/REST_Controller.php';
5
6class Login extends REST_Controller {
7
8    public function __construct()
9    {
10        parent::__construct('rest', TRUE);
11        $this->load->model('login_model');
12    }
13
14    public function index_post()
15    {
16        $user = $this->post('user');
17        $pass = $this->post('pass');
18
19        if($user == NULL || $pass == NULL) {
20            $this->response("missing arguments", 400);
21            return;
22        }
23
24        $userLoged = $this->login_model->Login($user,$pass);
25
26        if($userLoged) {
27
28            // Guardamos los resultados como objeto
29            $response = [
30                "data" => $userLoged
31            ];
32
33            $this->response($response, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
34
35        } else  {
36            $this->response([
37                $this->config->item('rest_status_field_name') => FALSE,
38                $this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized')
39            ], self::HTTP_UNAUTHORIZED);
40        }
41
42    }
43}
Note: See TracBrowser for help on using the repository browser.