/** * Reset a user's password * * @param string $email * @param string $password * @param string $code * @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 User's email address * * @return string */ public function email() { return Email::fromNative($this->email); }
/** @test */ public function should_create_from_native() { $email = Email::fromNative('*****@*****.**'); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\Email', $email); }