]> jfr.im git - z_archive/KronOS.git/blob - application/controllers/account.php
Added some index.html, removed redirect from login()
[z_archive/KronOS.git] / application / controllers / account.php
1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3 class Account extends CI_Controller {
4
5 public function __construct() {
6 # Required
7 parent::__construct();
8 $this->load->model('user');
9 }
10
11 public function index(){
12 }
13
14 public function login() {
15
16 # Login stuff
17 $user = $this->input->post('username');
18 $pass = $this->input->post('password');
19
20 if ($user == FALSE || $pass == FALSE) {
21 $this->json->error('Username or password was empty');
22 return;
23 }
24
25 if ($this->user->try_login($user, $pass)) {
26 $data = array(
27 'uid' => $this->user->uid(),
28 'sid' => $this->user->sid(),
29 'name' => $this->user->display_name(),
30 );
31 $this->json->reply('Logged in', $data);
32 } else {
33 $this->json->error('Incorrect credentials');
34 }
35 }
36 }