/** * 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)); }
/** * Get the User's email * * @return string */ public function email() { return Email::fromNative($this->email); }