コード例 #1
0
ファイル: Auth.php プロジェクト: razmir/wallacepos
 /**
  * Attempt a login; on success setup session vars and send to node server else log the failed attempt
  * @param $username
  * @param $password
  * @param bool $getToken When true,sets up an extended session token and auth_hash, which is returned to the client
  * @return bool|int
  */
 public function login($username, $password, $getToken = false)
 {
     $this->initAuthModel();
     $user = $this->authMdl->login($username, $password, true);
     if ($user == -1) {
         // log data
         Logger::write("An authentication attempt was made by " . $username . " but the user has been disabled.", "AUTH");
         return -1;
         // the user is disabled
     }
     if (is_array($user)) {
         // check for
         $_SESSION['username'] = $username;
         $_SESSION['userId'] = $user['id'];
         $_SESSION['isadmin'] = $user['admin'];
         $_SESSION['permissions'] = json_decode($user['permissions'], true);
         if ($getToken !== false) {
             $this->setNewSessionToken($user['id'], $user['hash']);
         }
         // log data
         Logger::write("Authentication successful for user:"******"AUTH");
         // Send to node JS
         $socket = new WposSocketIO();
         $socket->sendSessionData(session_id());
         /*if (!$socket->sendSessionData(session_id())){
               return -2;
           }*/
         return true;
     } else {
         // log data
         Logger::write("Authentication failed for user:"******" with hash:" . $password, "AUTH");
         return false;
     }
 }
コード例 #2
0
ファイル: AuthController.php プロジェクト: GutsVadim/phpMvc
 public function loginAction()
 {
     if (Request::isPost()) {
         $userName = $_POST['userName'];
         $password = $_POST['password'];
         $errors = [];
         if (AuthModel::login($userName, $password)) {
             header("Location: /");
             return;
         } else {
             $errors[] = 'Login failed';
         }
         $this->errors = $errors;
     }
     $this->title = 'Login page';
     $this->view("login");
 }
コード例 #3
0
<?php

require '../modelo/AuthModel.php';
require '../../../assets/libs/password_hash_lib/passwordLib.php';
extract($_POST);
if (empty($user) || empty($pass)) {
    echo "<script>alert('Por favor ingrese el usuario o contraseña');</script>";
    echo "<script>location.href='../vista/form_login.php';</script>";
} else {
    AuthModel::login($user, $pass);
}