1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-09 13:10:17 +00:00

Cleanup naming

This commit is contained in:
Alec Rippberger
2025-04-18 07:35:01 -05:00
parent 510399e257
commit 7d3460e737
2 changed files with 16 additions and 19 deletions

View File

@@ -9,7 +9,7 @@ import { ConfigService } from "@bitwarden/common/platform/abstractions/config/co
const TWO_FACTOR_AUTH_COMPONENT_CACHE_KEY = "two-factor-auth-component-cache";
/**
* This is a cache model for the two factor authentication data.
* Cache model for the two factor authentication data.
*/
export class TwoFactorAuthComponentCache {
token: string | undefined = undefined;
@@ -35,10 +35,7 @@ export interface TwoFactorAuthComponentData {
}
/**
* 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.
* Cache service used for the two factor auth component.
*/
@Injectable()
export class TwoFactorAuthComponentCacheService {
@@ -61,7 +58,7 @@ export class TwoFactorAuthComponentCacheService {
constructor() {}
/**
* Must be called once before interacting with the cached data, otherwise methods will be noop.
* Must be called once before interacting with the cached data.
*/
async init() {
this.featureEnabled = await this.configService.getFeatureFlag(
@@ -96,7 +93,7 @@ export class TwoFactorAuthComponentCacheService {
}
/**
* Returns the cached TwoFactorAuthData when available.
* Returns the cached TwoFactorAuthData (when available).
*/
getCachedData(): TwoFactorAuthComponentCache | null {
if (!this.featureEnabled) {

View File

@@ -180,18 +180,18 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
// Initialize the cache
await this.twoFactorAuthComponentCacheService.init();
// Load persisted form data if available
// Load cached form data if available
let loadedCachedProviderType = false;
const persistedData = this.twoFactorAuthComponentCacheService.getCachedData();
if (persistedData) {
if (persistedData.token) {
this.form.patchValue({ token: persistedData.token });
const cachedData = this.twoFactorAuthComponentCacheService.getCachedData();
if (cachedData) {
if (cachedData.token) {
this.form.patchValue({ token: cachedData.token });
}
if (persistedData.remember !== undefined) {
this.form.patchValue({ remember: persistedData.remember });
if (cachedData.remember !== undefined) {
this.form.patchValue({ remember: cachedData.remember });
}
if (persistedData.selectedProviderType !== undefined) {
this.selectedProviderType = persistedData.selectedProviderType;
if (cachedData.selectedProviderType !== undefined) {
this.selectedProviderType = cachedData.selectedProviderType;
loadedCachedProviderType = true;
}
}
@@ -328,7 +328,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
// In all flows but WebAuthn, the remember value is taken from the form.
const rememberValue = remember ?? this.rememberFormControl.value ?? false;
// Persist form data before submitting
// Cache form data before submitting
this.twoFactorAuthComponentCacheService.cacheData({
token: tokenValue,
remember: rememberValue,
@@ -355,7 +355,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
};
async selectOtherTwoFactorMethod() {
// Persist current form data before navigating to another method
// Cache current form data before navigating to another method
this.twoFactorAuthComponentCacheService.cacheData({
token: "",
remember: false,
@@ -375,7 +375,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
this.selectedProviderType = response.type;
await this.setAnonLayoutDataByTwoFactorProviderType();
// Update the persisted provider type when a new one is chosen
// Update the cached provider type when a new one is chosen
this.twoFactorAuthComponentCacheService.cacheData({
token: "",
remember: false,