1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

[PM-24677] Slim StateService down so it can be moved to state lib (#16021)

* Slim StateService down so it can be moved to state lib

* Fix accidental import changes

* Add `switchAccount` assertion

* Needs to use mock
This commit is contained in:
Justin Baur
2025-08-18 12:37:25 -04:00
committed by GitHub
parent ea305a0f71
commit 939fd402c3
49 changed files with 286 additions and 1274 deletions

View File

@@ -107,7 +107,8 @@ export class OssServeConfigurator {
);
this.generateCommand = new GenerateCommand(
this.serviceContainer.passwordGenerationService,
this.serviceContainer.stateService,
this.serviceContainer.tokenService,
this.serviceContainer.accountService,
);
this.syncCommand = new SyncCommand(this.serviceContainer.syncService);
this.statusCommand = new StatusCommand(
@@ -417,14 +418,18 @@ export class OssServeConfigurator {
}
protected async errorIfLocked(res: koa.Response) {
const authed = await this.serviceContainer.stateService.getIsAuthenticated();
const userId = await firstValueFrom(
this.serviceContainer.accountService.activeAccount$.pipe(map((account) => account?.id)),
);
const authed =
userId != null ||
(await firstValueFrom(this.serviceContainer.tokenService.hasAccessToken$(userId)));
if (!authed) {
this.processResponse(res, Response.error("You are not logged in."));
return true;
}
const userId = await firstValueFrom(
this.serviceContainer.accountService.activeAccount$.pipe(map((account) => account?.id)),
);
if (await this.serviceContainer.keyService.hasUserKey(userId)) {
return false;
}