示例#1
0
 public function userInit()
 {
     $user = null;
     $email = $this->userValues["contact"]["email"];
     try {
         $user = $this->userService->getUserEmail($email);
     } catch (Exceptions\NoResultException $ex) {
         $this->logger->addDebug($ex);
     }
     if ($user === null) {
         $this->logger->addInfo("Users module initializer - User - no user with email {$email} found. New one is gonna be created.");
         $addrValues = $this->userValues["contact"]["address"];
         $address = new Address((array) $addrValues);
         $address->applyAccountNumber($this->userValues["contact"]["address"]["accountNumber"]);
         $address->applyIdentificationNumber($this->userValues["contact"]["address"]["identificationNumber"]);
         $address->applyTaxIdentificationNumber($this->userValues["contact"]["address"]["taxIdentificationNumber"]);
         $contValues = $this->userValues["contact"];
         $contact = new Contact((array) $contValues);
         $contact->setAddress($address);
         $userValues = $this->userValues;
         unset($userValues["contact"]);
         $user = new User((array) $userValues);
         $user->setActive(true);
         $user->setContact($contact);
         $user->setBirthNumber("0000000000");
         $this->userService->createUser($user);
     }
 }
示例#2
0
 /**
  * @param Credentials  Prihlasovaci udaje.
  * @throws AuthenticationException Chyba v overeni udaju.
  * @return Identitu uzivatele.
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     try {
         $user = $this->usersService->getUserEmail($username);
     } catch (Exceptions\NoResultException $ex) {
         $this->getLogger()->addAlert("### ATTEMPT TO LOG IN WITH INVALID EMAIL ### - exception = " . $ex);
         throw new AuthenticationException("securityModule.loginControl.messages.invalidCredentials", self::IDENTITY_NOT_FOUND);
     }
     if (!Passwords::verify($password, $user->password)) {
         $this->getLogger()->addAlert("### ATTEMPT TO LOG IN WITH INVALID PASSWORD ### - tried password = "******"securityModule.loginControl.messages.invalidCredentials", self::INVALID_CREDENTIAL);
     }
     if (!$user->active) {
         $this->getLogger()->addAlert("### ATTEMPT TO LOG TO INACTIVE ACCOUNT ### - account id = " . $user->getId());
         throw new AuthenticationException("securityModule.loginControl.messages.userUnactive");
     }
     $this->usersService->updateLastLogin($user);
     $identity = $user;
     return $identity;
 }