Skip to content

Commit 88ce8e8

Browse files
committed
tweaks
1 parent 72402d2 commit 88ce8e8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function consumeLoginLink(Request $request): UserInterface
8282
$hash = $request->get('hash');
8383
$expires = $request->get('expires');
8484
if (false === hash_equals($hash, $this->computeSignatureHash($user, $expires))) {
85-
throw new InvalidLoginLinkException('User has changed since link was sent.');
85+
throw new InvalidLoginLinkException('Invalid or expired signature.');
8686
}
8787

8888
if ($expires < time()) {
@@ -107,6 +107,9 @@ private function computeSignatureHash(UserInterface $user, int $expires): string
107107

108108
foreach ($this->signatureProperties as $property) {
109109
$value = $this->propertyAccessor->getValue($user, $property);
110+
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
111+
throw new \InvalidArgumentException(sprintf('The property path "%s" on the user object "%s" must return a value that can be cast to a string, but "%s" was returned.', $property, get_class($user), get_debug_type($value)));
112+
}
110113
$signatureFields[] = base64_encode($value);
111114
}
112115

0 commit comments

Comments
 (0)