mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 20:24:01 +00:00
convert to key connector command localization
This commit is contained in:
@@ -19,6 +19,7 @@ import { KeyService } from "@bitwarden/key-management";
|
||||
import { ConvertToKeyConnectorCommand } from "../../key-management/convert-to-key-connector.command";
|
||||
import { Response } from "../../models/response";
|
||||
import { MessageResponse } from "../../models/response/message.response";
|
||||
import { I18nService } from "../../platform/services/i18n.service";
|
||||
import { CliUtils } from "../../utils";
|
||||
|
||||
export class UnlockCommand {
|
||||
@@ -33,6 +34,7 @@ export class UnlockCommand {
|
||||
private environmentService: EnvironmentService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||
private logout: () => Promise<void>,
|
||||
private i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
async run(password: string, cmdOptions: Record<string, any>) {
|
||||
@@ -78,6 +80,7 @@ export class UnlockCommand {
|
||||
this.environmentService,
|
||||
this.organizationApiService,
|
||||
this.logout,
|
||||
this.i18nService,
|
||||
);
|
||||
const convertResponse = await convertToKeyConnectorCommand.run();
|
||||
if (!convertResponse.success) {
|
||||
|
||||
@@ -181,6 +181,7 @@ export abstract class BaseProgram {
|
||||
this.serviceContainer.environmentService,
|
||||
this.serviceContainer.organizationApiService,
|
||||
this.serviceContainer.logout,
|
||||
this.serviceContainer.i18nService,
|
||||
);
|
||||
const response = await command.run(null, null);
|
||||
if (!response.success) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { Response } from "../models/response";
|
||||
import { MessageResponse } from "../models/response/message.response";
|
||||
import { I18nService } from "../platform/services/i18n.service";
|
||||
|
||||
import { ConvertToKeyConnectorCommand } from "./convert-to-key-connector.command";
|
||||
|
||||
@@ -38,6 +39,7 @@ describe("ConvertToKeyConnectorCommand", () => {
|
||||
const environmentService = mock<EnvironmentService>();
|
||||
const organizationApiService = mock<OrganizationApiServiceAbstraction>();
|
||||
const logout = jest.fn();
|
||||
const i18nService = mock<I18nService>();
|
||||
|
||||
beforeEach(async () => {
|
||||
command = new ConvertToKeyConnectorCommand(
|
||||
@@ -46,31 +48,30 @@ describe("ConvertToKeyConnectorCommand", () => {
|
||||
environmentService,
|
||||
organizationApiService,
|
||||
logout,
|
||||
i18nService,
|
||||
);
|
||||
});
|
||||
|
||||
describe("run", () => {
|
||||
it("should logout and return error response if no interaction available", async () => {
|
||||
process.env.BW_NOINTERACTION = "true";
|
||||
const errorMessage =
|
||||
"An organization you are a member of is using Key Connector. In order to access the vault, you must opt-in to Key Connector now via the web vault. You have been logged out.";
|
||||
i18nService.t.mockReturnValue(errorMessage);
|
||||
|
||||
const response = await command.run();
|
||||
|
||||
expect(response).not.toBeNull();
|
||||
expect(response.success).toEqual(false);
|
||||
expect(response).toEqual(
|
||||
Response.error(
|
||||
new MessageResponse(
|
||||
"An organization you are a member of is using Key Connector. In order to access the vault, you must opt-in to Key Connector now via the web vault. You have been logged out.",
|
||||
null,
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(response).toEqual(Response.error(new MessageResponse(errorMessage, null)));
|
||||
expect(logout).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should logout and return error response if interaction answer is exit", async () => {
|
||||
process.env.BW_NOINTERACTION = "false";
|
||||
keyConnectorService.getManagingOrganization.mockResolvedValue(organization);
|
||||
const errorMessage = "You have been logged out.";
|
||||
i18nService.t.mockReturnValue(errorMessage);
|
||||
|
||||
(createPromptModule as jest.Mock).mockImplementation(() =>
|
||||
jest.fn(() => Promise.resolve({ convert: "exit" })),
|
||||
@@ -80,7 +81,7 @@ describe("ConvertToKeyConnectorCommand", () => {
|
||||
|
||||
expect(response).not.toBeNull();
|
||||
expect(response.success).toEqual(false);
|
||||
expect(response).toEqual(Response.error("You have been logged out."));
|
||||
expect(response).toEqual(Response.error(errorMessage));
|
||||
expect(logout).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { UserId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { Response } from "../models/response";
|
||||
import { MessageResponse } from "../models/response/message.response";
|
||||
import { I18nService } from "../platform/services/i18n.service";
|
||||
|
||||
export class ConvertToKeyConnectorCommand {
|
||||
constructor(
|
||||
@@ -19,6 +20,7 @@ export class ConvertToKeyConnectorCommand {
|
||||
private environmentService: EnvironmentService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||
private logout: () => Promise<void>,
|
||||
private i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
async run(): Promise<Response> {
|
||||
@@ -28,8 +30,7 @@ export class ConvertToKeyConnectorCommand {
|
||||
await this.logout();
|
||||
return Response.error(
|
||||
new MessageResponse(
|
||||
"An organization you are a member of is using Key Connector. " +
|
||||
"In order to access the vault, you must opt-in to Key Connector now via the web vault. You have been logged out.",
|
||||
this.i18nService.t("organizationUsingKeyConnectorOptInLoggedOut"),
|
||||
null,
|
||||
),
|
||||
);
|
||||
@@ -40,20 +41,21 @@ export class ConvertToKeyConnectorCommand {
|
||||
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({
|
||||
type: "list",
|
||||
name: "convert",
|
||||
message:
|
||||
organization.name +
|
||||
" is using a self-hosted key server. A master password is no longer required to log in for members of this organization. ",
|
||||
message: this.i18nService.t(
|
||||
"removeMasterPasswordForOrganizationUserKeyConnector",
|
||||
organization.name,
|
||||
),
|
||||
choices: [
|
||||
{
|
||||
name: "Remove master password and unlock",
|
||||
name: this.i18nService.t("removeMasterPasswordAndUnlock"),
|
||||
value: "remove",
|
||||
},
|
||||
{
|
||||
name: "Leave organization and unlock",
|
||||
name: this.i18nService.t("leaveOrganizationAndUnlock"),
|
||||
value: "leave",
|
||||
},
|
||||
{
|
||||
name: "Log out",
|
||||
name: this.i18nService.t("logOut"),
|
||||
value: "exit",
|
||||
},
|
||||
],
|
||||
@@ -79,7 +81,7 @@ export class ConvertToKeyConnectorCommand {
|
||||
return Response.success();
|
||||
} else {
|
||||
await this.logout();
|
||||
return Response.error("You have been logged out.");
|
||||
return Response.error(this.i18nService.t("youHaveBeenLoggedOut"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,5 +184,29 @@
|
||||
"example": "JustTrust.us"
|
||||
}
|
||||
}
|
||||
},
|
||||
"organizationUsingKeyConnectorOptInLoggedOut": {
|
||||
"message": "An organization you are a member of is using Key Connector. In order to access the vault, you must opt-in to Key Connector now via the web vault. You have been logged out."
|
||||
},
|
||||
"removeMasterPasswordForOrganizationUserKeyConnector": {
|
||||
"message": "$ORGANIZATION$ has updated its member decryption options. You no longer need a password when logging into Bitwarden. Please confirm the domain below with your organization administrator.",
|
||||
"placeholders": {
|
||||
"organization": {
|
||||
"content": "$1",
|
||||
"example": "My Org Name"
|
||||
}
|
||||
}
|
||||
},
|
||||
"removeMasterPasswordAndUnlock": {
|
||||
"message": "Remove master password and unlock"
|
||||
},
|
||||
"leaveOrganizationAndUnlock": {
|
||||
"message": "Leave organization and unlock"
|
||||
},
|
||||
"logOut": {
|
||||
"message": "Log out"
|
||||
},
|
||||
"youHaveBeenLoggedOut": {
|
||||
"message": "You have been logged out."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ export class OssServeConfigurator {
|
||||
this.serviceContainer.environmentService,
|
||||
this.serviceContainer.organizationApiService,
|
||||
async () => await this.serviceContainer.logout(),
|
||||
this.serviceContainer.i18nService,
|
||||
);
|
||||
|
||||
this.sendCreateCommand = new SendCreateCommand(
|
||||
|
||||
@@ -279,6 +279,7 @@ export class Program extends BaseProgram {
|
||||
this.serviceContainer.environmentService,
|
||||
this.serviceContainer.organizationApiService,
|
||||
async () => await this.serviceContainer.logout(),
|
||||
this.serviceContainer.i18nService,
|
||||
);
|
||||
const response = await command.run(password, cmd);
|
||||
this.processResponse(response);
|
||||
|
||||
Reference in New Issue
Block a user