Skip to content

Commit 36a2cc9

Browse files
committed
remove fallbackPasskeyLabel
1 parent 9edfd67 commit 36a2cc9

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

src/PasskeyAuthenticatable.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,25 @@ public function getPasskeyUserHandle(): string
5555
*
5656
* Shown prominently in authenticator UIs (registration prompts,
5757
* account pickers, password manager entries). Falls back from
58-
* `name` to `email` to an opaque label derived from the user
59-
* handle when those columns are absent.
58+
* `name` to `email` to the auth identifier when columns are absent.
6059
*/
6160
public function getPasskeyDisplayName(): string
6261
{
6362
return $this->getAttribute('name')
6463
?? $this->getAttribute('email')
65-
?? $this->fallbackPasskeyLabel();
64+
?? (string) $this->getAuthIdentifier();
6665
}
6766

6867
/**
6968
* Get the username for WebAuthn registration.
7069
*
7170
* Used as the account identifier in authenticator UIs, typically
7271
* rendered as the subtitle beneath the display name. Falls back
73-
* to an opaque label derived from the user handle when `email`
74-
* is absent.
72+
* from `email` to the auth identifier when the column is absent.
7573
*/
7674
public function getPasskeyUsername(): string
7775
{
7876
return $this->getAttribute('email')
79-
?? $this->fallbackPasskeyLabel();
80-
}
81-
82-
/**
83-
* An opaque, stable label used when no name or email is available.
84-
*/
85-
protected function fallbackPasskeyLabel(): string
86-
{
87-
return 'user-'.substr(bin2hex($this->getPasskeyUserHandle()), 0, 10);
77+
?? (string) $this->getAuthIdentifier();
8878
}
8979
}

tests/Feature/PasskeyAuthenticatableTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,16 @@
3838
expect($user->getPasskeyUsername())->toBe('only@example.com');
3939
});
4040

41-
it('falls back to an opaque label when email is absent', function (): void {
42-
config(['passkeys.user_handle_secret' => 'test-secret']);
43-
41+
it('falls back to the auth identifier when email is absent', function (): void {
4442
Schema::create('bare_users', function (Blueprint $table): void {
4543
$table->id();
4644
$table->timestamps();
4745
});
4846

4947
$user = BareUser::create();
50-
$expected = 'user-'.substr(bin2hex($user->getPasskeyUserHandle()), 0, 10);
5148

52-
expect($user->getPasskeyDisplayName())->toBe($expected);
53-
expect($user->getPasskeyUsername())->toBe($expected);
54-
expect($expected)->not->toContain((string) $user->id);
49+
expect($user->getPasskeyDisplayName())->toBe((string) $user->id);
50+
expect($user->getPasskeyUsername())->toBe((string) $user->id);
5551
});
5652

5753
it('returns the same handle across fresh model instances', function (): void {

0 commit comments

Comments
 (0)