set user key once we detect session key (#9084)
This commit is contained in:
parent
a42de41587
commit
b4257e1c1c
|
@ -701,6 +701,8 @@ export class Main {
|
||||||
this.organizationExportService,
|
this.organizationExportService,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.cryptoService);
|
||||||
|
|
||||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||||
this.program = new Program(this);
|
this.program = new Program(this);
|
||||||
this.vaultProgram = new VaultProgram(this);
|
this.vaultProgram = new VaultProgram(this);
|
||||||
|
@ -724,8 +726,6 @@ export class Main {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.providerApiService = new ProviderApiService(this.apiService);
|
this.providerApiService = new ProviderApiService(this.apiService);
|
||||||
|
|
||||||
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.cryptoService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import * as chalk from "chalk";
|
import * as chalk from "chalk";
|
||||||
import { program, Command, OptionValues } from "commander";
|
import { program, Command, OptionValues } from "commander";
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
|
|
||||||
|
@ -63,8 +64,16 @@ export class Program {
|
||||||
process.env.BW_NOINTERACTION = "true";
|
process.env.BW_NOINTERACTION = "true";
|
||||||
});
|
});
|
||||||
|
|
||||||
program.on("option:session", (key) => {
|
program.on("option:session", async (key) => {
|
||||||
process.env.BW_SESSION = key;
|
process.env.BW_SESSION = key;
|
||||||
|
|
||||||
|
// once we have the session key, we can set the user key in memory
|
||||||
|
const activeAccount = await firstValueFrom(this.main.accountService.activeAccount$);
|
||||||
|
if (activeAccount) {
|
||||||
|
await this.main.userAutoUnlockKeyService.setUserKeyInMemoryIfAutoUserKeySet(
|
||||||
|
activeAccount.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
program.on("command:*", () => {
|
program.on("command:*", () => {
|
||||||
|
|
Loading…
Reference in New Issue