Skip to content

Commit a8812bd

Browse files
fix(email): throw when authenticated user has no email or wrong email
The previous condition only checked for a mismatch when the user had a non-empty email address. Users without an email (e.g. the admin) would silently pass through, letting the page load with nodeId: 0 and showing the generic "Document not found" error. Invert the guard: allow only when email matches, otherwise throw with a clear message asking the user to log out. Also improves the error message from the generic "Invalid user" to "This document is not yours. Log out and use the sign link again." Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 83b60c6 commit a8812bd

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

lib/Service/IdentifyMethod/Email.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,16 @@ private function throwIfIsAuthenticatedWithDifferentAccount(): void {
130130
return;
131131
}
132132
$email = $this->entity->getIdentifierValue();
133-
if (!empty($user->getEMailAddress()) && $user->getEMailAddress() !== $email) {
134-
if ($this->getEntity()->getCode() && !$this->getEntity()->getIdentifiedAtDate()) {
135-
return;
136-
}
137-
throw new LibresignException(json_encode([
138-
'action' => JSActions::ACTION_DO_NOTHING,
139-
'errors' => [['message' => $this->identifyService->getL10n()->t('Invalid user')]],
140-
]));
133+
if (!empty($user->getEMailAddress()) && $user->getEMailAddress() === $email) {
134+
return;
141135
}
136+
if ($this->getEntity()->getCode() && !$this->getEntity()->getIdentifiedAtDate()) {
137+
return;
138+
}
139+
throw new LibresignException(json_encode([
140+
'action' => JSActions::ACTION_DO_NOTHING,
141+
'errors' => [['message' => $this->identifyService->getL10n()->t('This document is not yours. Log out and use the sign link again.')]],
142+
]));
142143
}
143144

144145
private function throwIfAccountAlreadyExists(): void {

0 commit comments

Comments
 (0)