mirror of
https://github.com/bitwarden/browser
synced 2026-01-01 08:03:20 +00:00
[bug] Default rememberEmail to true (#1429)
This commit is contained in:
@@ -1,13 +1,36 @@
|
||||
import { StateService as BaseStateService } from "jslib-common/services/state.service";
|
||||
|
||||
import { Account } from "../models/account";
|
||||
import { GlobalState } from "../models/globalState";
|
||||
|
||||
import { StateService as StateServiceAbstraction } from "jslib-common/abstractions/state.service";
|
||||
import { StateService as StateServiceAbstraction } from "../abstractions/state.service";
|
||||
|
||||
export class StateService extends BaseStateService<Account> implements StateServiceAbstraction {
|
||||
import { StorageOptions } from "jslib-common/models/domain/storageOptions";
|
||||
|
||||
export class StateService
|
||||
extends BaseStateService<Account, GlobalState>
|
||||
implements StateServiceAbstraction
|
||||
{
|
||||
async addAccount(account: Account) {
|
||||
// Apply web overides to default account values
|
||||
account = new Account(account);
|
||||
await super.addAccount(account);
|
||||
}
|
||||
|
||||
async getRememberEmail(options?: StorageOptions) {
|
||||
return (
|
||||
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||
)?.rememberEmail;
|
||||
}
|
||||
|
||||
async setRememberEmail(value: boolean, options?: StorageOptions): Promise<void> {
|
||||
const globals = await this.getGlobals(
|
||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||
);
|
||||
globals.rememberEmail = value;
|
||||
await this.saveGlobals(
|
||||
globals,
|
||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
11
src/services/stateMigration.service.ts
Normal file
11
src/services/stateMigration.service.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { StateMigrationService as BaseStateMigrationService } from "jslib-common/services/stateMigration.service";
|
||||
import { GlobalState } from "../models/globalState";
|
||||
|
||||
export class StateMigrationService extends BaseStateMigrationService<GlobalState> {
|
||||
protected async migrationStateFrom1To2(): Promise<void> {
|
||||
await super.migrateStateFrom1To2();
|
||||
const globals = (await this.get<GlobalState>("global")) ?? this.globalStateFactory.create();
|
||||
globals.rememberEmail = (await this.get<boolean>("rememberEmail")) ?? globals.rememberEmail;
|
||||
await this.set("global", globals);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user