當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserMapper::isValidUser方法代碼示例

本文整理匯總了PHP中UserMapper::isValidUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserMapper::isValidUser方法的具體用法?PHP UserMapper::isValidUser怎麽用?PHP UserMapper::isValidUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserMapper的用法示例。


在下文中一共展示了UserMapper::isValidUser方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: login

 public function login()
 {
     if (isset($_POST["username"])) {
         // reaching via HTTP Post...
         //process login form
         if ($this->userMapper->isValidUser($_POST["username"], $_POST["passwd"])) {
             $_SESSION["currentuser"] = $_POST["username"];
             $_SESSION["tipoUsuario"] = $this->userMapper->userType($_POST["username"]);
             switch ($this->userMapper->userType($_POST["username"])) {
                 case "organizador":
                     $this->view->moveToFragment($_POST["username"]);
                     $this->view->redirect("organizador", "index");
                     break;
                 case "juradoPopular":
                     $this->view->moveToFragment($_POST["username"]);
                     $this->view->redirect("juradoPopular", "index");
                     break;
                 case "juradoProfesional":
                     $this->view->moveToFragment($_POST["username"]);
                     $this->view->redirect("juradoProfesional", "index");
                     break;
                 case "establecimiento":
                     $this->view->moveToFragment($_POST["username"]);
                     $this->view->redirect("establecimiento", "index");
                     break;
             }
         } else {
             $errors = array();
             $errors["general"] = "<span id=\"error\">El usuario o la contraseña no es correcta</span>";
             $this->view->setVariable("errors", $errors);
         }
     }
     // render the view (/view/users/login.php)
     $this->view->render("users", "login");
 }
開發者ID:xrlopez,項目名稱:ABP,代碼行數:35,代碼來源:UsersController.php

示例2: login

 public function login()
 {
     if (isset($_POST["login"])) {
         // reaching via HTTP Post...
         //process login form
         $usuarioLogueado = $this->userMapper->isValidUser($_POST["login"], $_POST["passwd"]);
         if ($usuarioLogueado) {
             $_SESSION["currentuser"] = $_POST["login"];
             // send user to the restricted area (HTTP 302 code)
             $this->view->redirect("users", "index");
         } else {
             $errors = array();
             $errors["general"] = "Username is not valid";
             $this->view->setVariable("errors", $errors);
         }
     }
     // render the view (/view/users/login.php)
     $this->view->setLayout("index");
     $this->view->render("users", "body");
 }
開發者ID:ragomez,項目名稱:abp2015,代碼行數:20,代碼來源:UsersController.php

示例3: login_user

 public static function login_user($user, $pass)
 {
     if ($user && $pass) {
         if ($usertype = UserMapper::isValidUser($user, $pass)) {
             return UserMapper::findByEmail($user, $usertype);
         } else {
             echo "ERROR: user or password incorrect";
         }
     } else {
         return "error, fields not validated";
     }
 }
開發者ID:ndrs92,項目名稱:PinchoWire,代碼行數:12,代碼來源:usuario.php

示例4: update

 public function update()
 {
     $userid = $_REQUEST["usuario"];
     $user = $this->userMapper->findById($userid);
     $errors = array();
     $pass = md5($_POST["passActual"]);
     if ($this->userMapper->isValidUser($_POST["usuario"], $pass)) {
         if (isset($_POST["usuario"])) {
             $user->setNombre($_POST["nombre"]);
             $user->setApellidos($_POST["apellidos"]);
             $user->setCorreo($_POST["correo"]);
             if (isset($_FILES['img'])) {
                 $img = $_FILES['img']['name'];
                 $ext = strrchr($img, '.');
                 $ruta = 'imagenes/user_' . $user->getId() . $ext;
                 if (move_uploaded_file($_FILES['img']['tmp_name'], $ruta)) {
                     $user->setImagen($user->getId() . $ext);
                 }
             }
             if (!(strlen(trim($_POST["passNew"])) == 0)) {
                 if ($_POST["passNew"] == $_POST["passNueva"]) {
                     $passNew = md5($_POST["passNew"]);
                     $user->setPassword($passNew);
                 } else {
                     $errors["pass"] = i18n("Passwords must be equal");
                     $this->view->setVariable("errors", $errors);
                     $this->view->setVariable("user", $user);
                     $this->view->render("users", "modificar");
                     return false;
                 }
             }
             try {
                 $this->userMapper->update($user);
                 $this->view->setFlash(i18n("Modified user correctly"));
                 $this->view->redirect("users", "perfil");
             } catch (ValidationException $ex) {
                 $errors = $ex->getErrors();
                 $this->view->setVariable("errors", $errors);
             }
         }
     } else {
         $errors["passActual"] = i18n("Incorrect password");
         $this->view->setVariable("errors", $errors);
         $this->view->setVariable("user", $user);
         $this->view->render("users", "modificar");
     }
 }
開發者ID:xrlopez,項目名稱:TSW,代碼行數:47,代碼來源:UsersController.php

示例5: authenticateUser

 /**
  * Authenticates the current request. If the request does not contain
  * auth credentials, it will generate a 401 response code and end PHP processing
  * If the request contain credentials, it will be checked against the database.
  * If the credentials are ok, it will return the User object just logged. If the
  * credentials are invalid, it will generate a 401 code as well and end PHP
  * processing.
  *
  * @return User the user just authenticated.
  */
 public function authenticateUser()
 {
     if (!isset($_SERVER['PHP_AUTH_USER'])) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized');
         header('WWW-Authenticate: Basic realm="Rest API of MVCBLOG"');
         die('This operation requires authentication');
     } else {
         $userMapper = new UserMapper();
         if ($userMapper->isValidUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
             return new User($_SERVER['PHP_AUTH_USER']);
         } else {
             header($_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized');
             header('WWW-Authenticate: Basic realm="Rest API of MVCBLOG"');
             die('The username/password is not valid');
         }
     }
 }
開發者ID:xrlopez,項目名稱:TSW,代碼行數:27,代碼來源:BaseRest.php


注:本文中的UserMapper::isValidUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。