mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +00:00
PM-4661: Add passkey.username as item.username (#9756)
* Add incoming passkey.username as item.username * Driveby fix, was sending wrong username * added username to new-cipher too * Guarded the if-block * Update apps/browser/src/vault/popup/components/vault/add-edit.component.ts Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> * Fixed broken test * fixed username on existing ciphers --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
@@ -256,7 +256,7 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
const name = data.credentialName || data.rpId;
|
||||
// TODO: Revert to check for user verification once user verification for passkeys is approved for production.
|
||||
// PM-4577 - https://github.com/bitwarden/clients/pull/8746
|
||||
await this.createNewCipher(name);
|
||||
await this.createNewCipher(name, data.userName);
|
||||
|
||||
// We are bypassing user verification pending approval.
|
||||
this.send({
|
||||
@@ -310,6 +310,7 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
name: data.credentialName || data.rpId,
|
||||
uri: this.url,
|
||||
uilocation: "popout",
|
||||
username: data.userName,
|
||||
senderTabId: this.senderTabId,
|
||||
sessionId: this.sessionId,
|
||||
userVerification: data.userVerification,
|
||||
@@ -357,11 +358,13 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
private buildCipher(name: string) {
|
||||
private buildCipher(name: string, username: string) {
|
||||
this.cipher = new CipherView();
|
||||
this.cipher.name = name;
|
||||
|
||||
this.cipher.type = CipherType.Login;
|
||||
this.cipher.login = new LoginView();
|
||||
this.cipher.login.username = username;
|
||||
this.cipher.login.uris = [new LoginUriView()];
|
||||
this.cipher.login.uris[0].uri = this.url;
|
||||
this.cipher.card = new CardView();
|
||||
@@ -371,8 +374,8 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
this.cipher.reprompt = CipherRepromptType.None;
|
||||
}
|
||||
|
||||
private async createNewCipher(name: string) {
|
||||
this.buildCipher(name);
|
||||
private async createNewCipher(name: string, username: string) {
|
||||
this.buildCipher(name, username);
|
||||
const cipher = await this.cipherService.encrypt(this.cipher);
|
||||
try {
|
||||
await this.cipherService.createWithServer(cipher);
|
||||
|
||||
@@ -128,6 +128,14 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
await this.load();
|
||||
|
||||
if (!this.editMode || this.cloneMode) {
|
||||
// Only allow setting username if there's no existing value
|
||||
if (
|
||||
params.username &&
|
||||
(this.cipher.login.username == null || this.cipher.login.username === "")
|
||||
) {
|
||||
this.cipher.login.username = params.username;
|
||||
}
|
||||
|
||||
if (params.name && (this.cipher.name == null || this.cipher.name === "")) {
|
||||
this.cipher.name = params.name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user