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 | * Authenticator constructor. |
||
25 | * |
||
26 | * @param \Illuminate\Http\Request $request |
||
27 | */ |
||
28 | 7 | public function __construct(IlluminateRequest $request) |
|
32 | |||
33 | /** |
||
34 | * Authenticator boot. |
||
35 | * |
||
36 | * @param $request |
||
37 | * |
||
38 | * @return Google2FA |
||
39 | */ |
||
40 | 7 | public function boot($request) |
|
46 | |||
47 | /** |
||
48 | * Fire login (success or failed). |
||
49 | * |
||
50 | * @param $succeeded |
||
51 | */ |
||
52 | 5 | private function fireLoginEvent($succeeded) |
|
62 | |||
63 | /** |
||
64 | * Get the OTP from user input. |
||
65 | * |
||
66 | * @throws InvalidOneTimePassword |
||
67 | * |
||
68 | * @return mixed |
||
69 | */ |
||
70 | 5 | protected function getOneTimePassword() |
|
71 | { |
||
72 | 5 | if (is_null($password = $this->getInputOneTimePassword()) || empty($password)) { |
|
73 | event(new EmptyOneTimePasswordReceived()); |
||
74 | |||
75 | if ($this->config('throw_exceptions', true)) { |
||
76 | throw new InvalidOneTimePassword('One Time Password cannot be empty.'); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | 5 | return $password; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * Check if the current use is authenticated via OTP. |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | 7 | public function isAuthenticated() |
|
94 | |||
95 | /** |
||
96 | * Check if it is already logged in or passable without checking for an OTP. |
||
97 | * |
||
98 | * @return bool |
||
99 | */ |
||
100 | 7 | protected function canPassWithoutCheckingOTP() |
|
108 | |||
109 | /** |
||
110 | * Check if the input OTP is valid. |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | 7 | protected function checkOTP() |
|
126 | |||
127 | /** |
||
128 | * Verify the OTP. |
||
129 | * |
||
130 | * @return mixed |
||
131 | */ |
||
132 | 5 | protected function verifyOneTimePassword() |
|
136 | } |
||
137 |