|
200 | 200 | // ------------------------------------ |
201 | 201 |
|
202 | 202 | } else if ($fn === 'processCreate') { |
203 | | - $clientDataJSON = base64_decode($post->clientDataJSON); |
204 | | - $attestationObject = base64_decode($post->attestationObject); |
205 | | - $challenge = $_SESSION['challenge']; |
| 203 | + $clientDataJSON = !empty($post->clientDataJSON) ? base64_decode($post->clientDataJSON) : null; |
| 204 | + $attestationObject = !empty($post->attestationObject) ? base64_decode($post->attestationObject) : null; |
| 205 | + $challenge = $_SESSION['challenge'] ?? null; |
206 | 206 |
|
207 | 207 | // processCreate returns data to be stored for future logins. |
208 | 208 | // in this example we store it in the php session. |
209 | | - // Normaly you have to store the data in a database connected |
210 | | - // with the user name. |
| 209 | + // Normally you have to store the data in a database connected |
| 210 | + // with the username. |
211 | 211 | $data = $WebAuthn->processCreate($clientDataJSON, $attestationObject, $challenge, $userVerification === 'required', true, false); |
212 | 212 |
|
213 | 213 | // add user infos |
|
239 | 239 | // ------------------------------------ |
240 | 240 |
|
241 | 241 | } else if ($fn === 'processGet') { |
242 | | - $clientDataJSON = base64_decode($post->clientDataJSON); |
243 | | - $authenticatorData = base64_decode($post->authenticatorData); |
244 | | - $signature = base64_decode($post->signature); |
245 | | - $userHandle = base64_decode($post->userHandle); |
246 | | - $id = base64_decode($post->id); |
| 242 | + $clientDataJSON = !empty($post->clientDataJSON) ? base64_decode($post->clientDataJSON) : null; |
| 243 | + $authenticatorData = !empty($post->authenticatorData) ? base64_decode($post->authenticatorData) : null; |
| 244 | + $signature = !empty($post->signature) ? base64_decode($post->signature) : null; |
| 245 | + $userHandle = !empty($post->userHandle) ? base64_decode($post->userHandle) : null; |
| 246 | + $id = !empty($post->id) ? base64_decode($post->id) : null; |
247 | 247 | $challenge = $_SESSION['challenge'] ?? ''; |
248 | 248 | $credentialPublicKey = null; |
249 | 249 |
|
|
0 commit comments