Fix: consistently check allowed domains (#2985)
* fix: ensure consistency of checking allowed domain * chore: update comment to match the logic
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import invariant from "invariant";
|
||||
import Logger from "@server/logging/logger";
|
||||
import { Team, AuthenticationProvider } from "@server/models";
|
||||
import { getAllowedDomains } from "@server/utils/authentication";
|
||||
import { isDomainAllowed } from "@server/utils/authentication";
|
||||
import { generateAvatarUrl } from "@server/utils/avatars";
|
||||
import { MaximumTeamsError } from "../errors";
|
||||
|
||||
@@ -57,9 +57,9 @@ export default async function teamCreator({
|
||||
const teamCount = await Team.count();
|
||||
|
||||
// If the self-hosted installation has a single team and the domain for the
|
||||
// new team matches one in the allowed domains env variable then assign the
|
||||
// authentication provider to the existing team
|
||||
if (teamCount === 1 && domain && getAllowedDomains().includes(domain)) {
|
||||
// new team is allowed then assign the authentication provider to the
|
||||
// existing team
|
||||
if (teamCount === 1 && domain && isDomainAllowed(domain)) {
|
||||
const team = await Team.findOne();
|
||||
invariant(team, "Team should exist");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user