mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 13:40:06 +00:00
Update naming for consistency
This commit is contained in:
@@ -34,7 +34,7 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
|
||||
import { TwoFactorAuthCacheService } from "../../common/services/auth-request/two-factor-auth-cache.service";
|
||||
import { TwoFactorAuthComponentCacheService } from "../../common/services/auth-request/two-factor-auth-cache.service";
|
||||
import { AnonLayoutWrapperDataService } from "../anon-layout/anon-layout-wrapper-data.service";
|
||||
|
||||
import { TwoFactorAuthComponentService } from "./two-factor-auth-component.service";
|
||||
@@ -71,7 +71,7 @@ describe("TwoFactorAuthComponent", () => {
|
||||
let anonLayoutWrapperDataService: MockProxy<AnonLayoutWrapperDataService>;
|
||||
let mockEnvService: MockProxy<EnvironmentService>;
|
||||
let mockLoginSuccessHandlerService: MockProxy<LoginSuccessHandlerService>;
|
||||
let mockTwoFactorAuthCacheService: MockProxy<TwoFactorAuthCacheService>;
|
||||
let mockTwoFactorAuthCompCacheService: MockProxy<TwoFactorAuthComponentCacheService>;
|
||||
|
||||
let mockUserDecryptionOpts: {
|
||||
noMasterPassword: UserDecryptionOptions;
|
||||
@@ -112,9 +112,9 @@ describe("TwoFactorAuthComponent", () => {
|
||||
|
||||
anonLayoutWrapperDataService = mock<AnonLayoutWrapperDataService>();
|
||||
|
||||
mockTwoFactorAuthCacheService = mock<TwoFactorAuthCacheService>();
|
||||
mockTwoFactorAuthCacheService.getCachedTwoFactorAuth.mockReturnValue(null);
|
||||
mockTwoFactorAuthCacheService.init.mockResolvedValue();
|
||||
mockTwoFactorAuthCompCacheService = mock<TwoFactorAuthComponentCacheService>();
|
||||
mockTwoFactorAuthCompCacheService.getCachedData.mockReturnValue(null);
|
||||
mockTwoFactorAuthCompCacheService.init.mockResolvedValue();
|
||||
|
||||
mockUserDecryptionOpts = {
|
||||
noMasterPassword: new UserDecryptionOptions({
|
||||
@@ -200,7 +200,10 @@ describe("TwoFactorAuthComponent", () => {
|
||||
{ provide: EnvironmentService, useValue: mockEnvService },
|
||||
{ provide: AnonLayoutWrapperDataService, useValue: anonLayoutWrapperDataService },
|
||||
{ provide: LoginSuccessHandlerService, useValue: mockLoginSuccessHandlerService },
|
||||
{ provide: TwoFactorAuthCacheService, useValue: mockTwoFactorAuthCacheService },
|
||||
{
|
||||
provide: TwoFactorAuthComponentCacheService,
|
||||
useValue: mockTwoFactorAuthCompCacheService,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import {
|
||||
ToastService,
|
||||
} from "@bitwarden/components";
|
||||
|
||||
import { TwoFactorAuthCacheService } from "../../common/services/auth-request/two-factor-auth-cache.service";
|
||||
import { TwoFactorAuthComponentCacheService } from "../../common/services/auth-request/two-factor-auth-cache.service";
|
||||
import { AnonLayoutWrapperDataService } from "../anon-layout/anon-layout-wrapper-data.service";
|
||||
import {
|
||||
TwoFactorAuthAuthenticatorIcon,
|
||||
@@ -103,7 +103,7 @@ interface TwoFactorCacheData {
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: TwoFactorAuthCacheService,
|
||||
provide: TwoFactorAuthComponentCacheService,
|
||||
},
|
||||
],
|
||||
})
|
||||
@@ -180,7 +180,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
private anonLayoutWrapperDataService: AnonLayoutWrapperDataService,
|
||||
private environmentService: EnvironmentService,
|
||||
private loginSuccessHandlerService: LoginSuccessHandlerService,
|
||||
private twoFactorCacheService: TwoFactorAuthCacheService,
|
||||
private twoFactorCacheService: TwoFactorAuthComponentCacheService,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -194,7 +194,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
|
||||
// Load persisted form data if available
|
||||
let loadedCachedProviderType = false;
|
||||
const persistedData = this.twoFactorCacheService.getCachedTwoFactorAuth();
|
||||
const persistedData = this.twoFactorCacheService.getCachedData();
|
||||
if (persistedData) {
|
||||
if (persistedData.token) {
|
||||
this.form.patchValue({ token: persistedData.token });
|
||||
@@ -233,9 +233,9 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
async saveFormDataWithPartialData(data: Partial<TwoFactorCacheData>) {
|
||||
// Get current cached data
|
||||
const currentData = this.twoFactorCacheService.getCachedTwoFactorAuth();
|
||||
const currentData = this.twoFactorCacheService.getCachedData();
|
||||
|
||||
this.twoFactorCacheService.cacheTwoFactorAuth({
|
||||
this.twoFactorCacheService.cacheData({
|
||||
token: data?.token ?? currentData?.token ?? "",
|
||||
remember: data?.remember ?? currentData?.remember ?? false,
|
||||
selectedProviderType:
|
||||
@@ -347,7 +347,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
const rememberValue = remember ?? this.rememberFormControl.value ?? false;
|
||||
|
||||
// Persist form data before submitting
|
||||
this.twoFactorCacheService.cacheTwoFactorAuth({
|
||||
this.twoFactorCacheService.cacheData({
|
||||
token: tokenValue,
|
||||
remember: rememberValue,
|
||||
selectedProviderType: this.selectedProviderType,
|
||||
@@ -375,7 +375,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
|
||||
async selectOtherTwoFactorMethod() {
|
||||
// Persist current form data before navigating to another method
|
||||
this.twoFactorCacheService.cacheTwoFactorAuth({
|
||||
this.twoFactorCacheService.cacheData({
|
||||
token: "",
|
||||
remember: false,
|
||||
selectedProviderType: this.selectedProviderType,
|
||||
@@ -396,7 +396,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
await this.setAnonLayoutDataByTwoFactorProviderType();
|
||||
|
||||
// Update the persisted provider type when a new one is chosen
|
||||
this.twoFactorCacheService.cacheTwoFactorAuth({
|
||||
this.twoFactorCacheService.cacheData({
|
||||
token: "",
|
||||
remember: false,
|
||||
selectedProviderType: response.type,
|
||||
@@ -481,7 +481,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
|
||||
|
||||
private async handleAuthResult(authResult: AuthResult) {
|
||||
// Clear form cache
|
||||
this.twoFactorCacheService.clearCachedTwoFactorAuth();
|
||||
this.twoFactorCacheService.clearCachedData();
|
||||
|
||||
if (await this.handleMigrateEncryptionKey(authResult)) {
|
||||
return; // stop login process
|
||||
|
||||
@@ -30,13 +30,13 @@ export interface TwoFactorAuthData {
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a cache service used for the login via auth request component.
|
||||
* This is a cache service used for the two factor auth component.
|
||||
*
|
||||
* There is sensitive information stored temporarily here. Cache will be cleared
|
||||
* after 2 minutes.
|
||||
*/
|
||||
@Injectable()
|
||||
export class TwoFactorAuthCacheService {
|
||||
export class TwoFactorAuthComponentCacheService {
|
||||
private viewCacheService: ViewCacheService = inject(ViewCacheService);
|
||||
private configService: ConfigService = inject(ConfigService);
|
||||
|
||||
@@ -67,7 +67,7 @@ export class TwoFactorAuthCacheService {
|
||||
/**
|
||||
* Update the cache with the new TwoFactorAuthData.
|
||||
*/
|
||||
cacheTwoFactorAuth(data: TwoFactorAuthData): void {
|
||||
cacheData(data: TwoFactorAuthData): void {
|
||||
if (!this.featureEnabled) {
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export class TwoFactorAuthCacheService {
|
||||
/**
|
||||
* Clears the cached TwoFactorAuthData.
|
||||
*/
|
||||
clearCachedTwoFactorAuth(): void {
|
||||
clearCachedData(): void {
|
||||
if (!this.featureEnabled) {
|
||||
return;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export class TwoFactorAuthCacheService {
|
||||
/**
|
||||
* Returns the cached TwoFactorAuthData when available.
|
||||
*/
|
||||
getCachedTwoFactorAuth(): TwoFactorAuthCache | null {
|
||||
getCachedData(): TwoFactorAuthCache | null {
|
||||
if (!this.featureEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user