Skip to content

Commit

Permalink
Bugs/allow empty (#252)
Browse files Browse the repository at this point in the history
Allow null for username
  • Loading branch information
Spomky authored Aug 29, 2022
1 parent 2051744 commit 01a2df9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/stimulus/Resources/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class default_1 extends Controller {
}
function removeEmpty(obj) {
return Object.entries(obj)
.filter(([_, v]) => v !== null)
.filter(([_, v]) => (v !== null && v !== ''))
.reduce((acc, [k, v]) => (Object.assign(Object.assign({}, acc), { [k]: v === Object(v) ? removeEmpty(v) : v })), {});
}
return removeEmpty({
Expand Down
2 changes: 1 addition & 1 deletion src/stimulus/Resources/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class extends Controller {

function removeEmpty(obj) {
return Object.entries(obj)
.filter(([_, v]) => v !== null)
.filter(([_, v]) => (v !== null && v !== ''))
.reduce(
(acc, [k, v]) => ({...acc, [k]: v === Object(v) ? removeEmpty(v) : v}),
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
use Webauthn\AuthenticatorSelectionCriteria;
use Webauthn\PublicKeyCredentialCreationOptions;

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

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE,
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT,
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT,
])]
public string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
public ?string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED,
Expand All @@ -36,7 +34,6 @@ final class AdditionalPublicKeyCredentialCreationOptionsRequest
])]
public ?string $userVerification = AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_NO_PREFERENCE,
Expand All @@ -46,7 +43,6 @@ final class AdditionalPublicKeyCredentialCreationOptionsRequest
])]
public string $residentKey = AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_PREFERRED;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@

use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
use Webauthn\AuthenticatorSelectionCriteria;
use Webauthn\PublicKeyCredentialCreationOptions;

final class ServerPublicKeyCredentialCreationOptionsRequest
{
#[Type(type: 'string')]
#[NotBlank]
public string $username = '';

#[Type(type: 'string')]
#[NotBlank]
public string $displayName = '';

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

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE,
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT,
PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT,
])]
public string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
public ?string $attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED,
Expand All @@ -44,7 +40,6 @@ final class ServerPublicKeyCredentialCreationOptionsRequest
])]
public ?string $userVerification = AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_NO_PREFERENCE,
Expand All @@ -54,7 +49,6 @@ final class ServerPublicKeyCredentialCreationOptionsRequest
])]
public ?string $residentKey = AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_PREFERRED;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
use Webauthn\PublicKeyCredentialRequestOptions;

final class ServerPublicKeyCredentialRequestOptionsRequest
{
#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
public ?string $username = null;

#[Type(type: 'string')]
#[NotBlank(allowNull: true)]
#[Choice(choices: [
PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_PREFERRED,
Expand Down

0 comments on commit 01a2df9

Please sign in to comment.