chore: Remove DEPLOYMENT and SUBDOMAINS_ENABLED (#5742)
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import sharedEnv from "@shared/env";
|
||||
import SigninEmail from "@server/emails/templates/SigninEmail";
|
||||
import WelcomeEmail from "@server/emails/templates/WelcomeEmail";
|
||||
import env from "@server/env";
|
||||
import { AuthenticationProvider } from "@server/models";
|
||||
import { buildUser, buildGuestUser, buildTeam } from "@server/test/factories";
|
||||
import { getTestServer } from "@server/test/support";
|
||||
import { getTestServer, setCloudHosted } from "@server/test/support";
|
||||
|
||||
const server = getTestServer();
|
||||
|
||||
describe("email", () => {
|
||||
beforeEach(setCloudHosted);
|
||||
|
||||
it("should require email param", async () => {
|
||||
const res = await server.post("/auth/email", {
|
||||
body: {},
|
||||
@@ -21,11 +21,19 @@ describe("email", () => {
|
||||
|
||||
it("should respond with redirect location when user is SSO enabled", async () => {
|
||||
const spy = jest.spyOn(WelcomeEmail.prototype, "schedule");
|
||||
const user = await buildUser();
|
||||
const team = await buildTeam({
|
||||
subdomain: "example",
|
||||
});
|
||||
const user = await buildUser({
|
||||
teamId: team.id,
|
||||
});
|
||||
const res = await server.post("/auth/email", {
|
||||
body: {
|
||||
email: user.email,
|
||||
},
|
||||
headers: {
|
||||
host: "example.outline.dev",
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
@@ -71,10 +79,6 @@ describe("email", () => {
|
||||
});
|
||||
|
||||
it("should not send email when user is on another subdomain but respond with success", async () => {
|
||||
env.URL = sharedEnv.URL = "https://app.outline.dev";
|
||||
env.SUBDOMAINS_ENABLED = sharedEnv.SUBDOMAINS_ENABLED = true;
|
||||
env.DEPLOYMENT = "hosted";
|
||||
|
||||
const user = await buildUser();
|
||||
const spy = jest.spyOn(WelcomeEmail.prototype, "schedule");
|
||||
await buildTeam({
|
||||
@@ -138,11 +142,10 @@ describe("email", () => {
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
spy.mockRestore();
|
||||
});
|
||||
|
||||
describe("with multiple users matching email", () => {
|
||||
it("should default to current subdomain with SSO", async () => {
|
||||
const spy = jest.spyOn(SigninEmail.prototype, "schedule");
|
||||
env.URL = sharedEnv.URL = "https://app.outline.dev";
|
||||
env.SUBDOMAINS_ENABLED = sharedEnv.SUBDOMAINS_ENABLED = true;
|
||||
const email = "sso-user@example.org";
|
||||
const team = await buildTeam({
|
||||
subdomain: "example",
|
||||
@@ -171,8 +174,6 @@ describe("email", () => {
|
||||
|
||||
it("should default to current subdomain with guest email", async () => {
|
||||
const spy = jest.spyOn(SigninEmail.prototype, "schedule");
|
||||
env.URL = sharedEnv.URL = "https://app.outline.dev";
|
||||
env.SUBDOMAINS_ENABLED = sharedEnv.SUBDOMAINS_ENABLED = true;
|
||||
const email = "guest-user@example.org";
|
||||
const team = await buildTeam({
|
||||
subdomain: "example",
|
||||
|
||||
@@ -25,13 +25,13 @@ router.post(
|
||||
const domain = parseDomain(ctx.request.hostname);
|
||||
|
||||
let team: Team | null | undefined;
|
||||
if (!env.isCloudHosted()) {
|
||||
if (!env.isCloudHosted) {
|
||||
team = await Team.scope("withAuthenticationProviders").findOne();
|
||||
} else if (domain.custom) {
|
||||
team = await Team.scope("withAuthenticationProviders").findOne({
|
||||
where: { domain: domain.host },
|
||||
});
|
||||
} else if (env.SUBDOMAINS_ENABLED && domain.teamSubdomain) {
|
||||
} else if (domain.teamSubdomain) {
|
||||
team = await Team.scope("withAuthenticationProviders").findOne({
|
||||
where: { subdomain: domain.teamSubdomain },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user