Beispiel #1
0
 public function login_post()
 {
     $this->auth(true);
     try {
         $profile = $this->model->login($this->post('login'), $this->post('password'));
         if (!$profile) {
             $this->response(sprintf(lang('not_found'), ucfirst(lang('user'))), 404);
         }
         if ($this->post('device_token')) {
             $this->device_tokens_model->add_token($profile['id'], $this->post('device_token'));
         }
         $this->response($profile, 200);
     } catch (Exception $e) {
         $this->response($e->getMessage(), $e->getCode());
     }
 }
Beispiel #2
0
 function __construct()
 {
     //encryption
     require_once "encryption.php";
     if (isset($_GET['logout']) && $_GET['logout']) {
         $_SESSION['logged'] = FALSE;
         session_destroy();
     }
     $data['invalidEmailPass'] = "******";
     //Authentication logic
     if (isset($_POST['login'])) {
         //store form email and pass
         $email = $_POST['email'];
         $enc_password = encrypt_password($_POST['password']);
         $usersObj = new Users_model();
         if ($usersObj->login($email, $enc_password)) {
             $_SESSION['logged'] = TRUE;
             $_SESSION['email'] = $email;
             // $_SESSION['name'] = 'Alin';
             header('Location: http://188.166.119.187/workspace/ilear/MVC/part4/index.php?page=admin');
         } else {
             $data['invalidEmailPass'] = "******";
         }
     }
     // $data['condition'] = (isset($_SESSION['logged']) && $_SESSION['logged'] ===  TRUE);
     // $data['logged'] = "You are logged in!";
     // // $data['unlogged'] = "";
     $data['logged'] = isset($_SESSION['logged']) && $_SESSION['logged'] === TRUE ? "You are logged in!" : "";
     // $data['logged'] = "You are logged in!";
     $data['title'] = "LoginPage";
     // $data['mailSent'] = "Note that only phone number is optional!";
     $this->render('views/top.php', $data);
     $this->render('views/menu.php', $data);
     $this->render('views/login.php', $data);
     $this->render('views/bottom.php', $data);
 }