fix: Do not show authentication provider plugins that aren't enabled

This commit is contained in:
Tom Moor
2023-02-18 13:56:03 -05:00
parent aece719a07
commit 66b5dd0a2b

View File

@@ -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,
});