@@ 48-56 (lines=9) @@ | ||
45 | $this->session = $session; |
|
46 | } |
|
47 | ||
48 | public function logAuthenticationMoment() |
|
49 | { |
|
50 | if ($this->isAuthenticationMomentLogged()) { |
|
51 | throw new LogicException('Cannot log authentication moment as an authentication moment is already logged'); |
|
52 | } |
|
53 | ||
54 | $this->session->set(self::AUTH_SESSION_KEY . 'authenticated_at', DateTime::now()->format(DateTime::FORMAT)); |
|
55 | $this->updateLastInteractionMoment(); |
|
56 | } |
|
57 | ||
58 | public function isAuthenticationMomentLogged() |
|
59 | { |
|
@@ 63-70 (lines=8) @@ | ||
60 | return $this->session->get(self::AUTH_SESSION_KEY . 'authenticated_at', null) !== null; |
|
61 | } |
|
62 | ||
63 | public function getAuthenticationMoment() |
|
64 | { |
|
65 | if (!$this->isAuthenticationMomentLogged()) { |
|
66 | throw new LogicException('Cannot get last authentication moment as no authentication has been set'); |
|
67 | } |
|
68 | ||
69 | return DateTime::fromString($this->session->get(self::AUTH_SESSION_KEY . 'authenticated_at')); |
|
70 | } |
|
71 | ||
72 | public function updateLastInteractionMoment() |
|
73 | { |