1 | <?php |
||
12 | class Authenticator extends Google2FA |
||
13 | { |
||
14 | use ErrorBag, Input, Response; |
||
15 | |||
16 | /** |
||
17 | * The current password. |
||
18 | * |
||
19 | * @var |
||
20 | */ |
||
21 | protected $password; |
||
22 | |||
23 | /** |
||
24 | * Flag to disable the session for API usage. |
||
25 | * |
||
26 | * @var |
||
27 | */ |
||
28 | protected $stateless = false; |
||
29 | |||
30 | /** |
||
31 | * Authenticator constructor. |
||
32 | * |
||
33 | * @param \Illuminate\Http\Request $request |
||
34 | */ |
||
35 | 8 | public function __construct(IlluminateRequest $request) |
|
39 | |||
40 | /** |
||
41 | * Authenticator boot. |
||
42 | * |
||
43 | * @param $request |
||
44 | * |
||
45 | * @return Google2FA |
||
46 | */ |
||
47 | 8 | public function boot($request) |
|
53 | |||
54 | /** |
||
55 | * Authenticator boot for API usage. |
||
56 | * |
||
57 | * @param $request |
||
58 | * |
||
59 | * @return Google2FA |
||
60 | */ |
||
61 | 1 | public function bootStateless($request) |
|
62 | { |
||
63 | 1 | $this->boot($request); |
|
64 | |||
65 | 1 | $this->setStateless(); |
|
66 | |||
67 | 1 | return $this; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * Fire login (success or failed). |
||
72 | * |
||
73 | * @param $succeeded |
||
74 | */ |
||
75 | 5 | private function fireLoginEvent($succeeded) |
|
85 | |||
86 | /** |
||
87 | * Get the OTP from user input. |
||
88 | * |
||
89 | * @throws InvalidOneTimePassword |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | 6 | protected function getOneTimePassword() |
|
105 | |||
106 | /** |
||
107 | * @return mixed |
||
108 | */ |
||
109 | public function getStateless() |
||
113 | |||
114 | /** |
||
115 | * Check if the current use is authenticated via OTP. |
||
116 | * |
||
117 | * @return bool |
||
118 | */ |
||
119 | 8 | public function isAuthenticated() |
|
125 | |||
126 | /** |
||
127 | * Check if it is already logged in or passable without checking for an OTP. |
||
128 | * |
||
129 | * @return bool |
||
130 | */ |
||
131 | 8 | protected function canPassWithoutCheckingOTP() |
|
139 | |||
140 | /** |
||
141 | * Check if the input OTP is valid. |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | 8 | protected function checkOTP() |
|
157 | |||
158 | /** |
||
159 | * @param mixed $stateless |
||
160 | * |
||
161 | * @return Authenticator |
||
162 | */ |
||
163 | 1 | public function setStateless($stateless = true) |
|
169 | |||
170 | /** |
||
171 | * Verify the OTP. |
||
172 | * |
||
173 | * @return mixed |
||
174 | * @throws InvalidOneTimePassword |
||
175 | */ |
||
176 | 6 | protected function verifyOneTimePassword() |
|
180 | } |
||
181 |