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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user