Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Restrict extends CI_Controller {
- public function index(){
- $data = array(
- 'scripts' => array(
- "util.js",
- "login.js"
- )
- );
- $this->template->show('login.php', $data);
- }
- public function ajax_login(){
- $result = false;
- $id = false;
- $json = array();
- $json['status'] = 1;
- $json['error_list'] = array();
- $username = $this->input->post("username");
- $password = $this->input->post("password");
- if (empty($username)) {
- $json['status'] = 0;
- $json['error_list']['#username'] = "Usuário não pode ser vazio!";
- }else {
- $this->load->model("users_model");
- $result = $this->users_model->get_user_data($username);
- }if ($result) {
- $id = $result->$id;
- $password_hash = $result->$password_hash;
- if (password_verify($password, $password_hash)) {
- $this->session->set_userdata("id", $id);
- }else {
- $json['status'] = 0;
- }
- }else {
- $json['status'] = 0;
- }
- if ($json['status'] == 0 ) {
- $json['error_list']['#btn_login'] = "Usuário e/ou senha incorretos!";
- }
- echo json_encode($json);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement