/** @test */ public function should_return_as_string() { $code = ReminderCode::fromNative('D1zcA5ncaEHzmjvCGjJIt3Kd8sGxTTtE7DkathqB'); $this->assertEquals('D1zcA5ncaEHzmjvCGjJIt3Kd8sGxTTtE7DkathqB', $code->toString()); $this->assertEquals('D1zcA5ncaEHzmjvCGjJIt3Kd8sGxTTtE7DkathqB', (string) $code); }
/** * 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"); }
/** * Get the Reminder code * * @return string */ public function code() { return ReminderCode::fromNative($this->code); }