PM-11427 Copy Totp Code without space (#10800)

This commit is contained in:
Jason Ng 2024-08-30 12:27:56 -04:00 committed by GitHub
parent c0fbb5ce39
commit d9ff8b0944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View File

@ -106,7 +106,7 @@
readonly readonly
bitInput bitInput
[type]="!(isPremium$ | async) ? 'password' : 'text'" [type]="!(isPremium$ | async) ? 'password' : 'text'"
[value]="totpCopyCode || '*** ***'" [value]="totpCodeCopyObj?.totpCodeFormatted || '*** ***'"
aria-readonly="true" aria-readonly="true"
data-testid="login-totp" data-testid="login-totp"
[disabled]="!(isPremium$ | async)" [disabled]="!(isPremium$ | async)"
@ -124,7 +124,7 @@
bitIconButton="bwi-clone" bitIconButton="bwi-clone"
bitSuffix bitSuffix
type="button" type="button"
[appCopyClick]="totpCopyCode" [appCopyClick]="totpCodeCopyObj?.totpCode"
[valueLabel]="'verificationCodeTotp' | i18n" [valueLabel]="'verificationCodeTotp' | i18n"
showToast showToast
[appA11yTitle]="'copyValue' | i18n" [appA11yTitle]="'copyValue' | i18n"

View File

@ -20,6 +20,11 @@ import {
import { BitTotpCountdownComponent } from "../../components/totp-countdown/totp-countdown.component"; import { BitTotpCountdownComponent } from "../../components/totp-countdown/totp-countdown.component";
type TotpCodeValues = {
totpCode: string;
totpCodeFormatted?: string;
};
@Component({ @Component({
selector: "app-login-credentials-view", selector: "app-login-credentials-view",
templateUrl: "login-credentials-view.component.html", templateUrl: "login-credentials-view.component.html",
@ -47,7 +52,7 @@ export class LoginCredentialsViewComponent {
); );
showPasswordCount: boolean = false; showPasswordCount: boolean = false;
passwordRevealed: boolean = false; passwordRevealed: boolean = false;
totpCopyCode: string; totpCodeCopyObj: TotpCodeValues;
private datePipe = inject(DatePipe); private datePipe = inject(DatePipe);
constructor( constructor(
@ -77,7 +82,7 @@ export class LoginCredentialsViewComponent {
this.showPasswordCount = !this.showPasswordCount; this.showPasswordCount = !this.showPasswordCount;
} }
setTotpCopyCode(e: any) { setTotpCopyCode(e: TotpCodeValues) {
this.totpCopyCode = e; this.totpCodeCopyObj = e;
} }
} }

View File

@ -44,13 +44,16 @@ export class BitTotpCountdownComponent implements OnInit {
if (this.totpCode != null) { if (this.totpCode != null) {
if (this.totpCode.length > 4) { if (this.totpCode.length > 4) {
this.totpCodeFormatted = this.formatTotpCode(); this.totpCodeFormatted = this.formatTotpCode();
this.sendCopyCode.emit(this.totpCodeFormatted); this.sendCopyCode.emit({
totpCode: this.totpCode,
totpCodeFormatted: this.totpCodeFormatted,
});
} else { } else {
this.totpCodeFormatted = this.totpCode; this.totpCodeFormatted = this.totpCode;
} }
} else { } else {
this.totpCodeFormatted = null; this.totpCodeFormatted = null;
this.sendCopyCode.emit(this.totpCodeFormatted); this.sendCopyCode.emit({ totpCode: null, totpCodeFormatted: null });
this.clearTotp(); this.clearTotp();
} }
} }