/** * Reset a user's password * * @param string $email * @param string $password * @param string $code * @throws InvalidValueException * @return User; */ public function reset($email, $password, $code) { if ($this->check($email, $code)) { $user = $this->findUserByEmail(Email::fromNative($email)); $password = $this->hasher->hash(new Password($password)); $user->resetPassword($password); $this->users->update($user); $this->reminders->deleteReminderByCode(ReminderCode::fromNative($code)); return $user; } throw new InvalidValueException("{$code} is not a valid reminder code"); }
public static function create() { // return 'here'; $faker = Factory::create(); $identifier = UserId::generate(); $email = Email::fromNative($faker->email); $first = FirstName::fromNative($faker->word); $last = LastName::fromNative($faker->word); $username = Username::fromNative($faker->word); $password = HashedPassword::fromNative(str_random(10)); return User::create($identifier, $email, $first, $last, $username, $password); }
/** @test */ public function should_create_from_native() { $email = Email::fromNative('*****@*****.**'); $this->assertInstanceOf('Cffs\\Domain\\Model\\Identity\\Email', $email); }
/** * Create a new instance from a native form * * @param mixed $email * @param mixed $password * @return ValueObject */ public static function fromNative($email, $password) { return new Credentials(Email::fromNative($email), Password::fromNative($password)); }
/** * Delete existing Reminders for Email * * @param Email $email * @return void */ public function deleteExistingRemindersForEmail(Email $email) { $query = $this->em->createQuery('DELETE Cffs\\Domain\\Model\\Identity\\Reminder r WHERE r.email = :email'); $query->setParameters(['email' => $email->toString()]); $query->execute(); }
/** * Set the User's email * * @param Email $email * @return void */ private function setEmail(Email $email) { $this->email = $email->toString(); }
/** * Find a user by their email address * * @param Email $email * @return User */ public function userOfEmail(Email $email) { return $this->em->getRepository($this->class)->findOneBy(['email' => $email->toString()]); }