Пример #1
0
 /**
  * Attempts to register
  * @param  UserCredentials $uc
  * @return boolean
  * 
  */
 public function doRegister(UserCredentials $uc)
 {
     if ($uc->getName() == "") {
         return false;
     } else {
         if ($uc->getPassword() == "") {
             return false;
         } else {
             if (strlen($uc->getName()) < 3) {
                 return false;
             } else {
                 if (strlen($uc->getPassword()) < 6) {
                     return false;
                 } else {
                     if (strcmp($uc->getPassword(), $uc->getTempPassword()) !== 0) {
                         return false;
                     } else {
                         if ($this->usernameExists($uc->getName())) {
                             return false;
                         } else {
                             if (preg_match('/[^a-zA-Z0-9]+/', $uc->getName(), $matches)) {
                                 return false;
                             } else {
                                 $this->registerUser($uc->getName(), $uc->getPassword());
                                 $this->message = "Registered new user.";
                                 return true;
                             }
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
Пример #2
0
 /**
  * Attempts to authenticate
  * @param  UserCredentials $uc
  * @return boolean
  */
 public function doLogin(UserCredentials $uc)
 {
     $this->matchingPassword = $this->rcDAL->load($uc->getName());
     $loginByUsernameAndPassword = \Settings::USERNAME === $uc->getName() && \Settings::PASSWORD === $uc->getPassword() || $this->matchingPassword != "" && password_verify($uc->getPassword(), $this->matchingPassword);
     if ($loginByUsernameAndPassword) {
         $user = new LoggedInUser($uc);
         $_SESSION[self::$sessionUserLocation] = $user;
         return true;
     }
     return false;
 }
Пример #3
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;
 }
Пример #4
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Пример #6
0
 public function __construct(UserCredentials $uc)
 {
     $this->userName = $uc->getName();
     $this->client = $uc->getClient();
 }