Пример #1
0
 public function it_has_and_can_change_email_address()
 {
     $this->getEmailAddress()->shouldReturn($this->emailAddress);
     $newEmail = EmailAddress::get('*****@*****.**');
     $this->setEmailAddress($newEmail)->shouldReturn($this);
     $this->getEmailAddress()->shouldReturn($newEmail);
 }
Пример #2
0
 public function it_can_be_executed(InputInterface $input, OutputInterface $output, User $user)
 {
     $email = '*****@*****.**';
     $input->getArgument('email-address')->willReturn($email);
     $this->userRepository->getByEmailAddress(EmailAddress::get($email))->willReturn($user);
     $this->userRepository->delete($user)->shouldBeCalled();
     $this->execute($input, $output);
 }
Пример #3
0
 public function getByEmailAddress(EmailAddress $emailAddress) : User
 {
     return $this->getUserFromRow($this->getRow('
             SELECT user_uuid, email_address, password, display_name, created, updated
               FROM users
         INNER JOIN objects ON (user_uuid = uuid AND type = "users")
              WHERE email_address = :email_address
     ', ['email_address' => $emailAddress->toString()]));
 }
Пример #4
0
 public function it_can_be_executed_and_derive_display_name(InputInterface $input, OutputInterface $output)
 {
     $email = '*****@*****.**';
     $pass = '******';
     $input->getArgument('email-address')->willReturn($email);
     $input->getArgument('password')->willReturn($pass);
     $input->getArgument('display-name')->willReturn('');
     $this->authenticationService->createUser(EmailAddress::get($email), $pass, 'joe');
     $this->execute($input, $output);
 }
Пример #5
0
 private function getUserByEmail(string $email) : User
 {
     try {
         $emailAddress = EmailAddress::get($email);
         return $this->userRepository->getByEmailAddress($emailAddress);
     } catch (NoUniqueResultException $exception) {
         throw LoginFailedException::invalidCredentials($exception);
     } catch (\InvalidArgumentException $exception) {
         throw LoginFailedException::invalidEmailAddress();
     }
 }
Пример #6
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $user = $this->userRepository->getByEmailAddress(EmailAddress::get($input->getArgument('email-address')));
     $this->userRepository->delete($user);
 }
Пример #7
0
 public function it_can_retrieve_a_user_by_email(\PDOStatement $statement)
 {
     $userUuid = Uuid::uuid4();
     $userRow = ['user_uuid' => $userUuid->getBytes(), 'email_address' => '*****@*****.**', 'password' => password_hash('no.siblings.as.far.as.i.know', PASSWORD_BCRYPT), 'display_name' => 'Princess Leia', 'created' => '1977-05-25 00:11:38', 'updated' => '1997-01-31 00:11:38'];
     $this->pdo->prepare(new Argument\Token\StringContainsToken('FROM users'))->willReturn($statement);
     $statement->execute(['email_address' => $userRow['email_address']])->shouldBeCalled();
     $statement->rowCount()->willReturn(1);
     $statement->fetch(\PDO::FETCH_ASSOC)->willReturn($userRow);
     $user = $this->getByEmailAddress(EmailAddress::get($userRow['email_address']));
     $user->shouldHaveType(User::class);
     $user->getUuid()->equals($userUuid)->shouldReturn(true);
     $user->getEmailAddress()->toString()->shouldReturn($userRow['email_address']);
     $user->getPassword()->shouldReturn($userRow['password']);
     $user->getDisplayName()->shouldReturn($userRow['display_name']);
 }
 public function it_errors_on_general_error()
 {
     $email = '*****@*****.**';
     $password = '******';
     $this->userRepository->getByEmailAddress(EmailAddress::get($email))->willThrow(new \RuntimeException());
     $this->shouldThrow(LoginFailedException::systemError())->duringLogin($email, $password);
 }
Пример #9
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->authenticationService->createUser(EmailAddress::get($input->getArgument('email-address')), $input->getArgument('password'), $this->getDisplayName($input->getArgument('display-name'), $input->getArgument('email-address')));
 }