Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'TOOLS/Response.php';
- require_once 'const/GlobalParams.php';
- require_once 'LoggerManager.php';
- class Login extends CI_Controller {
- function __construct() {
- parent::__construct();
- }
- function index() {
- $this->load->helper('url');
- $this->load->library('session');
- $this->load->model('Users');
- $users = $this->Users->FETCH_ALL(true);
- $data['users'] =$users;
- $this->load->view('login_view',$data);
- }
- function VerifyLogin(){
- $obj =& get_instance();
- $logger = new LoggerManager($obj);
- $jsonObj = json_decode($_POST["json"]);
- $this->load->model('Users');
- $response = new Response();
- $id = $jsonObj->id;
- $password = $jsonObj->password;
- $result = $this->Users->LOGIN($id, $password);//sha1($password));
- if(sizeof ($result)==0)
- {
- $response->Status ="badPassword";
- }
- else
- if ( $newPassword!=null )
- {
- $id_user = $result[0]->id_pracownicy;
- $update = array('password' =>sha1($newPassword));
- $this->Users->UPDATE($id_user,$update);
- $response->Status ="updated";
- }
- else
- {
- $this->load->model('Sessiondata');
- $guid =$this->Sessiondata->ADD_NEW_SESSION($result[0]->id_pracownicy,$result[0]->username);
- $response->Status ="loggedIn";
- $response->Guid = $guid;
- $response->Key = $this->generateKey($result[0]->id_pracownicy, $result[0]->username);
- $response->Content =$this->Users->FETCH_ALL_EDITOR();
- }
- $logger->LOG_LOGIN($id,$response->Status);
- echo json_encode($response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement