Пример #1
0
 /**
  * @param CredentialsDto $credentials
  * @return mixed
  * @throws \Exception
  */
 public function login(CredentialsDto $credentials)
 {
     /* Check that all required credentials are set  */
     if ($credentials->getIpAddress() == "" || $credentials->getUserName() == "" || $credentials->getPassword() == "") {
         throw new \InvalidArgumentException("Required credentials have not been defined");
     }
     $identityModel = $this->getIdentity()->getIdentityByCredentials($credentials->getUserName());
     if (empty($identityModel)) {
         throw new \Exception("Invalid Username/Password");
     }
     if ($identityModel[0]['password'] != $this->hashPassword($credentials->getPassword())) {
         throw new \Exception("Username and/or password does not match.");
     }
     return $identityModel;
 }