diff --git a/server/models/helpers/AuthenticationHelper.ts b/server/models/helpers/AuthenticationHelper.ts index 4379a5605..27b49d33b 100644 --- a/server/models/helpers/AuthenticationHelper.ts +++ b/server/models/helpers/AuthenticationHelper.ts @@ -17,15 +17,22 @@ export default class AuthenticationHelper { return providerConfigs .sort((config) => (config.id === "email" ? 1 : -1)) .filter((config) => { - // guest sign-in is an exception as it does not have an authentication - // provider using passport, instead it exists as a boolean option on the team - if (config.id === "email") { - return team?.emailSigninEnabled; + // Don't return authentication methods that are not enabled. + if (!config.enabled) { + return false; } + + // If no team return all possible authentication providers. if (!team) { return true; } + // Guest sign-in is an exception as it does not have an authentication + // provider using passport, instead it exists as a boolean option. + if (config.id === "email") { + return team?.emailSigninEnabled; + } + const authProvider = find(team.authenticationProviders, { name: config.id, });