コード例 #1
0
 /**
  * Attempts to authenticate
  * @param  UserCredentials $uc
  * @return boolean
  */
 public function doLogin(UserCredentials $uc)
 {
     $this->tempCredentials = $this->tempDAL->load($uc->getName());
     $loginByUsernameAndPassword = \Settings::USERNAME === $uc->getName() && \Settings::PASSWORD === $uc->getPassword();
     $loginByTemporaryCredentials = $this->tempCredentials != null && $this->tempCredentials->isValid($uc->getTempPassword());
     if ($loginByUsernameAndPassword || $loginByTemporaryCredentials) {
         $user = new LoggedInUser($uc);
         $_SESSION[self::$sessionUserLocation] = $user;
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * Attempts to authenticate
  * @param  UserCredentials $uc
  * @return boolean
  */
 public function doLogin(UserCredentials $uc)
 {
     $this->tempCredentials = $this->tempDAL->load($uc->getName());
     $this->userDAL = new \model\UserDAL($this->conn);
     $this->existingUser = $this->userDAL->getUserFromDatabase($uc);
     if ($this->existingUser == null) {
         $loginByUsernameAndPassword = false;
     } else {
         $loginByUsernameAndPassword = $this->existingUser->{"username"} === $uc->getName() && $this->existingUser->{"password"} === $uc->getPassword();
     }
     $loginByTemporaryCredentials = $this->tempCredentials != null && $this->tempCredentials->isValid($uc->getTempPassword());
     if ($loginByUsernameAndPassword || $loginByTemporaryCredentials) {
         $user = new LoggedInUser($uc);
         $_SESSION[self::$sessionUserLocation] = $user;
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: LoginModel.php プロジェクト: ej222ru/1DV608_A4
 /**
  * Attempts to authenticate
  * @param  UserCredentials $uc
  * @return boolean
  */
 public function doLogin(UserCredentials $uc, \model\RegisterModel $regModel)
 {
     $this->tempCredentials = $this->tempDAL->load($uc->getName());
     $loginByUsernameAndPassword = false;
     $userData = $regModel->getUser($uc->getName());
     if ($userData) {
         $userDataSep = explode("::", $userData);
         $pwDecrypt = password_verify(trim($uc->getPassword()), trim($userDataSep[1]));
         $loginByUsernameAndPassword = strcmp($uc->getName(), $userDataSep[0]) == 0 && $pwDecrypt;
         // $loginByUsernameAndPassword = (strcmp($uc->getName(), $userDataSep[0]) == 0) && (strcmp(trim($uc->getPassword()), trim($userDataSep[1])) == 0);
     } else {
         $loginByUsernameAndPassword = false;
     }
     $loginByTemporaryCredentials = $this->tempCredentials != null && $this->tempCredentials->isValid($uc->getTempPassword());
     if ($loginByUsernameAndPassword || $loginByTemporaryCredentials) {
         $user = new LoggedInUser($uc);
         $_SESSION[self::$sessionUserLocation] = $user;
         return true;
     }
     return false;
 }