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