| @@ 139-155 (lines=17) @@ | ||
| 136 | ||
| 137 | $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class); |
|
| 138 | ||
| 139 | if ($identity->getExpiresOn() < time()) { |
|
| 140 | $identity->setStatus(Entity\Identity::STATUS_EXPIRED); |
|
| 141 | $mapper->store($identity); |
|
| 142 | $this->logger->info('cookie expired', [ |
|
| 143 | 'input' => [ |
|
| 144 | 'user' => $userId, |
|
| 145 | 'series' => $series, |
|
| 146 | 'key' => $key, |
|
| 147 | ], |
|
| 148 | 'account' => [ |
|
| 149 | 'user' => $identity->getUserId(), |
|
| 150 | 'identity' => $identity->getId(), |
|
| 151 | ], |
|
| 152 | ]); |
|
| 153 | ||
| 154 | throw new IdentityExpired; |
|
| 155 | } |
|
| 156 | ||
| 157 | if ($identity->matchKey($key) === false) { |
|
| 158 | $identity->setStatus(Entity\Identity::STATUS_BLOCKED); |
|
| @@ 157-174 (lines=18) @@ | ||
| 154 | throw new IdentityExpired; |
|
| 155 | } |
|
| 156 | ||
| 157 | if ($identity->matchKey($key) === false) { |
|
| 158 | $identity->setStatus(Entity\Identity::STATUS_BLOCKED); |
|
| 159 | $mapper->store($identity); |
|
| 160 | ||
| 161 | $this->logger->error('compromised cookie', [ |
|
| 162 | 'input' => [ |
|
| 163 | 'user' => $userId, |
|
| 164 | 'series' => $series, |
|
| 165 | 'key' => $key, |
|
| 166 | ], |
|
| 167 | 'account' => [ |
|
| 168 | 'user' => $identity->getUserId(), |
|
| 169 | 'identity' => $identity->getId(), |
|
| 170 | ], |
|
| 171 | ]); |
|
| 172 | ||
| 173 | throw new CompromisedCookie; |
|
| 174 | } |
|
| 175 | ||
| 176 | $identity->generateNewKey(); |
|
| 177 | $identity->setLastUsed(time()); |
|
| @@ 253-270 (lines=18) @@ | ||
| 250 | ||
| 251 | $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class); |
|
| 252 | ||
| 253 | if ($identity->matchKey($key) === false) { |
|
| 254 | $identity->setStatus(Entity\Identity::STATUS_BLOCKED); |
|
| 255 | $mapper->store($identity); |
|
| 256 | ||
| 257 | $this->logger->error('compromised cookie', [ |
|
| 258 | 'input' => [ |
|
| 259 | 'user' => $userId, |
|
| 260 | 'series' => $series, |
|
| 261 | 'key' => $key, |
|
| 262 | ], |
|
| 263 | 'account' => [ |
|
| 264 | 'user' => $identity->getUserId(), |
|
| 265 | 'identity' => $identity->getId(), |
|
| 266 | ], |
|
| 267 | ]); |
|
| 268 | ||
| 269 | throw new CompromisedCookie; |
|
| 270 | } |
|
| 271 | ||
| 272 | $identity->setStatus(Entity\Identity::STATUS_DISCARDED); |
|
| 273 | $mapper->store($identity); |
|