Conditions | 7 |
Paths | 8 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | public function check(Authorization $authorization) |
||
25 | { |
||
26 | $userAccount = $authorization->getUserAccount(); |
||
27 | if (null === $userAccount) { |
||
28 | throw new RedirectToLoginPageException($authorization); |
||
29 | } |
||
30 | |||
31 | switch (true) { |
||
32 | case $authorization->hasQueryParam('max_age'): |
||
33 | $max_age = (int) $authorization->getQueryParam('max_age'); |
||
34 | |||
35 | break; |
||
36 | case $authorization->getClient()->has('default_max_age'): |
||
37 | $max_age = (int) $authorization->getClient()->get('default_max_age'); |
||
38 | |||
39 | break; |
||
40 | default: |
||
41 | return; |
||
42 | } |
||
43 | |||
44 | if ($authorization->isUserAccountFullyAuthenticated()) { |
||
45 | return; |
||
46 | } |
||
47 | |||
48 | if (null === $userAccount->getLastLoginAt() || time() - $userAccount->getLastLoginAt() > $max_age) { |
||
49 | throw new RedirectToLoginPageException($authorization); |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 |