1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-03 17:13:47 +00:00

Username generator (#1456)

* username generator implemented

* disable type when coming from add/edit

* restyle buttons to new icon-btn

* update generated-wrapper styles

* only show policy messages for passwords

* make generated-wrapper a standalone style

* Update src/app/vault/password-generator.component.html

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>

* aria-expanded on show options

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
This commit is contained in:
Kyle Spearrin
2022-03-29 15:01:57 -04:00
committed by GitHub
parent bc21703a2b
commit 9e0cc45704
13 changed files with 612 additions and 214 deletions

View File

@@ -120,8 +120,8 @@ export class VaultComponent implements OnInit, OnDestroy {
(document.querySelector("#search") as HTMLInputElement).select();
detectChanges = false;
break;
case "openPasswordGenerator":
await this.openPasswordGenerator(false);
case "openGenerator":
await this.openGenerator(false);
break;
case "syncCompleted":
await this.load();
@@ -599,28 +599,39 @@ export class VaultComponent implements OnInit, OnDestroy {
this.go();
}
async openPasswordGenerator(showSelect: boolean) {
async openGenerator(showSelect: boolean, passwordType = true) {
if (this.modal != null) {
this.modal.close();
}
const cipher = this.addEditComponent?.cipher;
const loginType = cipher != null && cipher.type === CipherType.Login && cipher.login != null;
const [modal, childComponent] = await this.modalService.openViewRef(
PasswordGeneratorComponent,
this.passwordGeneratorModalRef,
(comp) => (comp.showSelect = showSelect)
(comp) => {
comp.showSelect = showSelect;
if (showSelect) {
comp.type = passwordType ? "password" : "username";
if (loginType && cipher.login.hasUris && cipher.login.uris[0].hostname != null) {
comp.usernameWebsite = cipher.login.uris[0].hostname;
comp.showWebsiteOption = true;
}
}
}
);
this.modal = modal;
childComponent.onSelected.subscribe((password: string) => {
childComponent.onSelected.subscribe((value: string) => {
this.modal.close();
if (
this.addEditComponent != null &&
this.addEditComponent.cipher != null &&
this.addEditComponent.cipher.type === CipherType.Login &&
this.addEditComponent.cipher.login != null
) {
if (loginType) {
this.addEditComponent.markPasswordAsDirty();
this.addEditComponent.cipher.login.password = password;
if (passwordType) {
this.addEditComponent.cipher.login.password = value;
} else {
this.addEditComponent.cipher.login.username = value;
}
}
});