62 $token = $this->settings[
"userToken"];
65 curl_setopt_array($curl, array(
66 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/users/$this->userid/totp",
67 CURLOPT_RETURNTRANSFER =>
true,
68 CURLOPT_ENCODING =>
'',
69 CURLOPT_MAXREDIRS => 10,
71 CURLOPT_FOLLOWLOCATION =>
true,
72 CURLOPT_CUSTOMREQUEST =>
'POST',
73 CURLOPT_POSTFIELDS =>
"{}",
74 CURLOPT_HTTPHEADER => array(
75 "Content-Type: application/json",
76 "Accept: application/json",
77 "Authorization: Bearer $token"
81 $response = json_decode(curl_exec($curl));
83 if(isset($response->code)) {
84 throw new Exception(
"Error-Code: " . $response->code .
" Message: " . $response->message);
86 $this->totpUri = $response->uri;
87 $this->secret = $response->secret;
95 public function verify($verifyCode): bool
97 $token = $this->settings[
"userToken"];
100 curl_setopt_array($curl, array(
101 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/users/$this->userid/totp/verify",
102 CURLOPT_RETURNTRANSFER =>
true,
103 CURLOPT_ENCODING =>
'',
104 CURLOPT_MAXREDIRS => 10,
105 CURLOPT_TIMEOUT => 0,
106 CURLOPT_FOLLOWLOCATION =>
true,
107 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
108 CURLOPT_CUSTOMREQUEST =>
'POST',
109 CURLOPT_POSTFIELDS =>
"{
110 \"code\": \"$verifyCode\"
112 CURLOPT_HTTPHEADER => array(
113 "Content-Type: application/json",
114 "Accept: application/json",
115 "Authorization: Bearer $token"
119 $response = json_decode(curl_exec($curl));
121 if (isset($response->code)) {