[PM-129] Refactor email forwarding providers to remove filtering for self-hosted (#4963)
* Added model for email forwarder options * Refactored code base to use model and filter based on the new model
This commit is contained in:
parent
d74504ec72
commit
1666488672
|
@ -41,16 +41,8 @@ export class GeneratorComponent extends BaseGeneratorComponent {
|
||||||
window
|
window
|
||||||
);
|
);
|
||||||
if (platformUtilsService.isSelfHost()) {
|
if (platformUtilsService.isSelfHost()) {
|
||||||
// Cannot use Firefox Relay on self hosted web vaults due to CORS issues with Firefox Relay API
|
// Allow only valid email forwarders for self host
|
||||||
this.forwardOptions.splice(
|
this.forwardOptions = this.forwardOptions.filter((forwarder) => forwarder.validForSelfHosted);
|
||||||
this.forwardOptions.findIndex((o) => o.value === "firefoxrelay"),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
// Also cannot use Duck Duck Go on self hosted web vaults due to CORS issues
|
|
||||||
this.forwardOptions.splice(
|
|
||||||
this.forwardOptions.findIndex((o) => o.value === "duckduckgo"),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||||
|
import { EmailForwarderOptions } from "@bitwarden/common/models/domain/email-forwarder-options";
|
||||||
import { PasswordGeneratorPolicyOptions } from "@bitwarden/common/models/domain/password-generator-policy-options";
|
import { PasswordGeneratorPolicyOptions } from "@bitwarden/common/models/domain/password-generator-policy-options";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
||||||
import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username";
|
import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username";
|
||||||
|
@ -22,7 +23,7 @@ export class GeneratorComponent implements OnInit {
|
||||||
usernameTypeOptions: any[];
|
usernameTypeOptions: any[];
|
||||||
subaddressOptions: any[];
|
subaddressOptions: any[];
|
||||||
catchallOptions: any[];
|
catchallOptions: any[];
|
||||||
forwardOptions: any[];
|
forwardOptions: EmailForwarderOptions[];
|
||||||
usernameOptions: any = {};
|
usernameOptions: any = {};
|
||||||
passwordOptions: any = {};
|
passwordOptions: any = {};
|
||||||
username = "-";
|
username = "-";
|
||||||
|
@ -236,11 +237,11 @@ export class GeneratorComponent implements OnInit {
|
||||||
|
|
||||||
private async initForwardOptions() {
|
private async initForwardOptions() {
|
||||||
this.forwardOptions = [
|
this.forwardOptions = [
|
||||||
{ name: "AnonAddy", value: "anonaddy" },
|
{ name: "AnonAddy", value: "anonaddy", validForSelfHosted: true },
|
||||||
{ name: "DuckDuckGo", value: "duckduckgo" },
|
{ name: "DuckDuckGo", value: "duckduckgo", validForSelfHosted: false },
|
||||||
{ name: "Fastmail", value: "fastmail" },
|
{ name: "Fastmail", value: "fastmail", validForSelfHosted: true },
|
||||||
{ name: "Firefox Relay", value: "firefoxrelay" },
|
{ name: "Firefox Relay", value: "firefoxrelay", validForSelfHosted: false },
|
||||||
{ name: "SimpleLogin", value: "simplelogin" },
|
{ name: "SimpleLogin", value: "simplelogin", validForSelfHosted: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
this.usernameOptions = await this.usernameGenerationService.getOptions();
|
this.usernameOptions = await this.usernameGenerationService.getOptions();
|
||||||
|
@ -248,7 +249,7 @@ export class GeneratorComponent implements OnInit {
|
||||||
this.usernameOptions.forwardedService == null ||
|
this.usernameOptions.forwardedService == null ||
|
||||||
this.usernameOptions.forwardedService === ""
|
this.usernameOptions.forwardedService === ""
|
||||||
) {
|
) {
|
||||||
this.forwardOptions.push({ name: "", value: null });
|
this.forwardOptions.push({ name: "", value: null, validForSelfHosted: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.forwardOptions = this.forwardOptions.sort((a, b) => a.name.localeCompare(b.name));
|
this.forwardOptions = this.forwardOptions.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
export class EmailForwarderOptions {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
validForSelfHosted: boolean;
|
||||||
|
}
|
Loading…
Reference in New Issue