Skip to content

Commit 01a2df9

Browse files
authored
Bugs/allow empty (#252)
Allow null for username
1 parent 2051744 commit 01a2df9

5 files changed

+6
-19
lines changed

src/stimulus/Resources/assets/dist/controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class default_1 extends Controller {
9696
}
9797
function removeEmpty(obj) {
9898
return Object.entries(obj)
99-
.filter(([_, v]) => v !== null)
99+
.filter(([_, v]) => (v !== null && v !== ''))
100100
.reduce((acc, [k, v]) => (Object.assign(Object.assign({}, acc), { [k]: v === Object(v) ? removeEmpty(v) : v })), {});
101101
}
102102
return removeEmpty({

src/stimulus/Resources/assets/src/controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class extends Controller {
123123

124124
function removeEmpty(obj) {
125125
return Object.entries(obj)
126-
.filter(([_, v]) => v !== null)
126+
.filter(([_, v]) => (v !== null && v !== ''))
127127
.reduce(
128128
(acc, [k, v]) => ({...acc, [k]: v === Object(v) ? removeEmpty(v) : v}),
129129
{}

src/symfony/src/Dto/AdditionalPublicKeyCredentialCreationOptionsRequest.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Symfony\Component\Validator\Constraints\Choice;
88
use Symfony\Component\Validator\Constraints\NotBlank;
9-
use Symfony\Component\Validator\Constraints\Type;
109
use Webauthn\AuthenticatorSelectionCriteria;
1110
use Webauthn\PublicKeyCredentialCreationOptions;
1211

@@ -19,15 +18,14 @@ final class AdditionalPublicKeyCredentialCreationOptionsRequest
1918
*/
2019
public ?array $authenticatorSelection = null;
2120

22-
#[Type(type: 'string')]
21+
#[NotBlank(allowNull: true)]
2322
#[Choice(choices: [
2423
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE,
2524
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT,
2625
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT,
2726
])]
28-
public string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
27+
public ?string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
2928

30-
#[Type(type: 'string')]
3129
#[NotBlank(allowNull: true)]
3230
#[Choice(choices: [
3331
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED,
@@ -36,7 +34,6 @@ final class AdditionalPublicKeyCredentialCreationOptionsRequest
3634
])]
3735
public ?string $userVerification = AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED;
3836

39-
#[Type(type: 'string')]
4037
#[NotBlank(allowNull: true)]
4138
#[Choice(choices: [
4239
AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_NO_PREFERENCE,
@@ -46,7 +43,6 @@ final class AdditionalPublicKeyCredentialCreationOptionsRequest
4643
])]
4744
public string $residentKey = AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_PREFERRED;
4845

49-
#[Type(type: 'string')]
5046
#[NotBlank(allowNull: true)]
5147
#[Choice(choices: [
5248
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,

src/symfony/src/Dto/ServerPublicKeyCredentialCreationOptionsRequest.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66

77
use Symfony\Component\Validator\Constraints\Choice;
88
use Symfony\Component\Validator\Constraints\NotBlank;
9-
use Symfony\Component\Validator\Constraints\Type;
109
use Webauthn\AuthenticatorSelectionCriteria;
1110
use Webauthn\PublicKeyCredentialCreationOptions;
1211

1312
final class ServerPublicKeyCredentialCreationOptionsRequest
1413
{
15-
#[Type(type: 'string')]
1614
#[NotBlank]
1715
public string $username = '';
1816

19-
#[Type(type: 'string')]
2017
#[NotBlank]
2118
public string $displayName = '';
2219

@@ -27,15 +24,14 @@ final class ServerPublicKeyCredentialCreationOptionsRequest
2724
*/
2825
public ?array $authenticatorSelection = null;
2926

30-
#[Type(type: 'string')]
27+
#[NotBlank(allowNull: true)]
3128
#[Choice(choices: [
3229
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE,
3330
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT,
3431
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT,
3532
])]
36-
public string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
33+
public ?string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
3734

38-
#[Type(type: 'string')]
3935
#[NotBlank(allowNull: true)]
4036
#[Choice(choices: [
4137
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED,
@@ -44,7 +40,6 @@ final class ServerPublicKeyCredentialCreationOptionsRequest
4440
])]
4541
public ?string $userVerification = AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED;
4642

47-
#[Type(type: 'string')]
4843
#[NotBlank(allowNull: true)]
4944
#[Choice(choices: [
5045
AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_NO_PREFERENCE,
@@ -54,7 +49,6 @@ final class ServerPublicKeyCredentialCreationOptionsRequest
5449
])]
5550
public ?string $residentKey = AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_PREFERRED;
5651

57-
#[Type(type: 'string')]
5852
#[NotBlank(allowNull: true)]
5953
#[Choice(choices: [
6054
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,

src/symfony/src/Dto/ServerPublicKeyCredentialRequestOptionsRequest.php

-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66

77
use Symfony\Component\Validator\Constraints\Choice;
88
use Symfony\Component\Validator\Constraints\NotBlank;
9-
use Symfony\Component\Validator\Constraints\Type;
109
use Webauthn\PublicKeyCredentialRequestOptions;
1110

1211
final class ServerPublicKeyCredentialRequestOptionsRequest
1312
{
14-
#[Type(type: 'string')]
1513
#[NotBlank(allowNull: true)]
1614
public ?string $username = null;
1715

18-
#[Type(type: 'string')]
1916
#[NotBlank(allowNull: true)]
2017
#[Choice(choices: [
2118
PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_PREFERRED,

0 commit comments

Comments
 (0)