Exemple #1
0
 public function getIdentity()
 {
     $identity = parent::getIdentity();
     if ($identity !== null) {
         $identity = $this->userService->getById((int) $identity->getId());
     }
     return $identity;
 }
Exemple #2
0
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $user = $this->userService->getByEmail($email);
     if ($user === null) {
         throw new AuthenticationException(sprintf('User with e-mail %s not found.', $email), self::IDENTITY_NOT_FOUND);
     }
     if (!$user->equalsPassword($password)) {
         throw new AuthenticationException('Invalid password.', self::INVALID_CREDENTIAL);
     }
     return $user;
 }
 private function registerUser(RegistrationForm $form)
 {
     $values = $form->getValues();
     $user = new User($values->email, $values->password);
     $user->setName($values->address->name);
     $user->setStreet($values->address->street);
     $user->setCity($values->address->city);
     $user->setZip($values->address->zip);
     try {
         if (!$form->hasErrors()) {
             $this->userService->create($user);
             $this->flashMessage('Account has been created.');
             $this->user->login($user->getEmail(), $values->password);
             $this->currentCartService->consolidateCurrentCartWithCurrentUser();
             $this->restoreRequest($this->backlink);
             $this->redirect(':Front:Home:Homepage:');
         }
     } catch (EntityDuplicateException $e) {
         $form->addError(sprintf('User with e-mail %s already exists.', $user->getEmail()));
     }
 }