|
19 | 19 | class SwitchUserToken extends UsernamePasswordToken
|
20 | 20 | {
|
21 | 21 | private $originalToken;
|
| 22 | + private $originatedFromUri; |
22 | 23 |
|
23 | 24 | /**
|
24 |
| - * @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method |
25 |
| - * @param mixed $credentials This usually is the password of the user |
| 25 | + * @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method |
| 26 | + * @param mixed $credentials This usually is the password of the user |
| 27 | + * @param string|null $originatedFromUri The URI where was the user at the switch |
26 | 28 | *
|
27 | 29 | * @throws \InvalidArgumentException
|
28 | 30 | */
|
29 |
| - public function __construct($user, $credentials, string $firewallName, array $roles, TokenInterface $originalToken) |
| 31 | + public function __construct($user, $credentials, string $firewallName, array $roles, TokenInterface $originalToken, string $originatedFromUri = null) |
30 | 32 | {
|
31 | 33 | parent::__construct($user, $credentials, $firewallName, $roles);
|
32 | 34 |
|
33 | 35 | $this->originalToken = $originalToken;
|
| 36 | + $this->originatedFromUri = $originatedFromUri; |
34 | 37 | }
|
35 | 38 |
|
36 | 39 | public function getOriginalToken(): TokenInterface
|
37 | 40 | {
|
38 | 41 | return $this->originalToken;
|
39 | 42 | }
|
40 | 43 |
|
| 44 | + public function getOriginatedFromUri(): ?string |
| 45 | + { |
| 46 | + return $this->originatedFromUri; |
| 47 | + } |
| 48 | + |
41 | 49 | /**
|
42 | 50 | * {@inheritdoc}
|
43 | 51 | */
|
44 | 52 | public function __serialize(): array
|
45 | 53 | {
|
46 |
| - return [$this->originalToken, parent::__serialize()]; |
| 54 | + return [$this->originalToken, $this->originatedFromUri, parent::__serialize()]; |
47 | 55 | }
|
48 | 56 |
|
49 | 57 | /**
|
50 | 58 | * {@inheritdoc}
|
51 | 59 | */
|
52 | 60 | public function __unserialize(array $data): void
|
53 | 61 | {
|
54 |
| - [$this->originalToken, $parentData] = $data; |
| 62 | + [$this->originalToken, $this->originatedFromUri, $parentData] = $data; |
55 | 63 | $parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
|
56 | 64 | parent::__unserialize($parentData);
|
57 | 65 | }
|
|
0 commit comments