Skip to content

Commit 5507d9f

Browse files
janbarasekdg
authored andcommitted
SimpleIdentity: Identifier must be int|string. (#53)
1 parent 21d2516 commit 5507d9f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Security/Identity.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ public function __construct($id, $roles = null, iterable $data = null)
4949

5050
/**
5151
* Sets the ID of user.
52+
* @param string|int $id
5253
* @return static
5354
*/
5455
public function setId($id)
5556
{
57+
if (!is_string($id) && !is_int($id)) {
58+
throw new Nette\InvalidArgumentException('Identity identifier must be string|int, but type "' . gettype($id) . '" given.');
59+
}
5660
$this->id = is_numeric($id) && !is_float($tmp = $id * 1) ? $tmp : $id;
5761
return $this;
5862
}

0 commit comments

Comments
 (0)