| @@ 82-96 (lines=15) @@ | ||
| 79 | * |
|
| 80 | * @return void |
|
| 81 | */ |
|
| 82 | public function sendSmsToken(TwoFactorAuthenticatable $user) |
|
| 83 | { |
|
| 84 | try { |
|
| 85 | $options = $user->getTwoFactorAuthProviderOptions(); |
|
| 86 | ||
| 87 | $response = json_decode((new HttpClient())->get( |
|
| 88 | $this->config['api_url'].'/protected/json/sms/'.$options['id']. |
|
| 89 | '?force=true&api_key='.$this->config['api_key'] |
|
| 90 | )->getBody(), true); |
|
| 91 | ||
| 92 | return $response['success'] === true; |
|
| 93 | } catch (Exception $e) { |
|
| 94 | return false; |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * Start the user two-factor authentication via phone call. |
|
| @@ 105-119 (lines=15) @@ | ||
| 102 | * |
|
| 103 | * @return void |
|
| 104 | */ |
|
| 105 | public function sendPhoneCallToken(TwoFactorAuthenticatable $user) |
|
| 106 | { |
|
| 107 | try { |
|
| 108 | $options = $user->getTwoFactorAuthProviderOptions(); |
|
| 109 | ||
| 110 | $response = json_decode((new HttpClient())->get( |
|
| 111 | $this->config['api_url'].'/protected/json/call/'.$options['id']. |
|
| 112 | '?force=true&api_key='.$this->config['api_key'] |
|
| 113 | )->getBody(), true); |
|
| 114 | ||
| 115 | return $response['success'] === true; |
|
| 116 | } catch (Exception $e) { |
|
| 117 | return false; |
|
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| 121 | /** |
|
| 122 | * Determine if the given token is valid for the given user. |
|