Skip to content

Commit 8337eea

Browse files
committed
fix(auth): null check before calling getId() in verifyEmail
Split combined null/inactive check into separate guards to prevent "Call to a member function getId() on null" when no user is found for the verification token.
1 parent d7e893e commit 8337eea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Services/Auth/UserService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ public function verifyEmail(string $token): User
225225
return $this->tx_service->transaction(function () use ($token) {
226226
$user = $this->user_repository->getByVerificationEmailToken($token);
227227

228-
if (is_null($user) || !$user->isActive()) {
228+
if (is_null($user)) {
229+
Log::warning("UserService::verifyEmail no user found for token");
230+
throw new EntityNotFoundException();
231+
}
232+
233+
if (!$user->isActive()) {
229234
Log::warning(sprintf("UserService::verifyEmail user with id %s is not active", $user->getId()));
230235
throw new EntityNotFoundException();
231236
}

0 commit comments

Comments
 (0)