account refactor

This commit is contained in:
2023-10-17 18:30:41 +03:00
parent 23219ce998
commit d9736b29a4
17 changed files with 91 additions and 186 deletions
+17
View File
@@ -142,7 +142,24 @@ readonly class AuthService
{
$name = (new Name($name));
$this->userRepo->updateName($this->currentUserId(), $name);
$user = $this->userRepo->findById($this->currentUserId());
$this->session->put(["user" => $user->get()->safe()]);
}
/**
* @throws LucentException
*/
public function updateEmail(string $email): void
{
$email = (new Email($email));
$user = $this->userRepo->findByEmail($email);
if($user->isDefined()){
throw new LucentException("Email already assigned to user");
}
$this->userRepo->updateEmail($this->currentUserId(), $email);
$user = $this->userRepo->findById($this->currentUserId());
$this->session->put(["user" => $user->get()->safe()]);
}