mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[PM-12716] - add missing password generation function to send form password (#11273)
* add generatePassword function to send options * add generatePassword function
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
bitIconButton="bwi-generate"
|
||||
bitSuffix
|
||||
[appA11yTitle]="'generatePassword' | i18n"
|
||||
(click)="generatePassword()"
|
||||
data-testid="generate-password"
|
||||
></button>
|
||||
<bit-hint>{{ "sendPasswordDescV2" | i18n }}</bit-hint>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnInit } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||
import { map } from "rxjs";
|
||||
import { firstValueFrom, map } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
SectionHeaderComponent,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import { CredentialGeneratorService, Generators } from "@bitwarden/generator-core";
|
||||
|
||||
import { SendFormConfig } from "../../abstractions/send-form-config.service";
|
||||
import { SendFormContainer } from "../../send-form-container";
|
||||
@@ -72,6 +73,7 @@ export class SendOptionsComponent implements OnInit {
|
||||
private sendFormContainer: SendFormContainer,
|
||||
private formBuilder: FormBuilder,
|
||||
private policyService: PolicyService,
|
||||
private generatorService: CredentialGeneratorService,
|
||||
) {
|
||||
this.sendFormContainer.registerChildForm("sendOptionsForm", this.sendOptionsForm);
|
||||
this.policyService
|
||||
@@ -98,6 +100,16 @@ export class SendOptionsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
generatePassword = async () => {
|
||||
const generatedCredential = await firstValueFrom(
|
||||
this.generatorService.generate$(Generators.Password),
|
||||
);
|
||||
|
||||
this.sendOptionsForm.patchValue({
|
||||
password: generatedCredential.credential,
|
||||
});
|
||||
};
|
||||
|
||||
ngOnInit() {
|
||||
if (this.sendFormContainer.originalSendView) {
|
||||
this.sendOptionsForm.patchValue({
|
||||
|
||||
Reference in New Issue
Block a user