1 | <?php |
||
19 | class Authenticator extends Google2FA |
||
20 | { |
||
21 | use ErrorBag, Input, Response, Session; |
||
22 | |||
23 | /** |
||
24 | * The current password. |
||
25 | * |
||
26 | * @var |
||
27 | */ |
||
28 | protected $password; |
||
29 | |||
30 | /** |
||
31 | * Authenticator constructor. |
||
32 | * |
||
33 | * @param \Illuminate\Http\Request $request |
||
34 | */ |
||
35 | 7 | public function __construct(IlluminateRequest $request) |
|
39 | |||
40 | /** |
||
41 | * Authenticator boot. |
||
42 | * |
||
43 | * @param $request |
||
44 | * |
||
45 | * @return Google2FA |
||
46 | */ |
||
47 | 7 | public function boot($request) |
|
53 | |||
54 | /** |
||
55 | * Authenticator boot for API usage. |
||
56 | * |
||
57 | * @param $request |
||
58 | * |
||
59 | * @return Google2FA |
||
60 | */ |
||
61 | public function bootStateless($request) |
||
62 | { |
||
63 | $this->boot($request); |
||
64 | |||
65 | $this->setStateless(); |
||
66 | |||
67 | return $this; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Removes expired tokens from the database. |
||
72 | */ |
||
73 | 6 | public function cleanupTokens(): void |
|
83 | |||
84 | /** |
||
85 | * Fire login (success or failed). |
||
86 | * |
||
87 | * @param $succeeded |
||
88 | * |
||
89 | */ |
||
90 | 4 | private function fireLoginEvent($succeeded) |
|
100 | |||
101 | /** |
||
102 | * Get the OTP from user input. |
||
103 | * |
||
104 | * @throws InvalidOneTimePassword |
||
105 | * |
||
106 | * @return mixed |
||
107 | */ |
||
108 | 5 | protected function getOneTimePassword() |
|
122 | |||
123 | /** |
||
124 | * Check if the current use is authenticated via OTP. |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | 7 | public function isAuthenticated() |
|
132 | |||
133 | /** |
||
134 | * @return bool |
||
135 | */ |
||
136 | 7 | public function hasValidCookieToken(): bool |
|
160 | |||
161 | /** |
||
162 | * Check if it is already logged in or passable without checking for an OTP. |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | 7 | protected function canPassWithoutCheckingOTP() |
|
174 | |||
175 | /** |
||
176 | * Check if the input OTP is valid. Returns one of the possible OTP_STATUS codes: |
||
177 | * 'empty', 'valid' or 'invalid'. |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | 7 | protected function checkOTP() |
|
198 | |||
199 | /** |
||
200 | * Verify the OTP. |
||
201 | * |
||
202 | * @throws InvalidOneTimePassword |
||
203 | * |
||
204 | * @return mixed |
||
205 | */ |
||
206 | 5 | protected function verifyOneTimePassword() |
|
210 | } |
||
211 |