fix: Users should not be redirected to disabled authentication providers (#5055

* fix: Users should not be redirected to disabled authentication providers
Re-enabled tests in plugin directory

* Fix plugin http tests
This commit is contained in:
Tom Moor
2023-03-18 09:17:54 -04:00
committed by GitHub
parent 6dd4afccaf
commit 41f97b0563
7 changed files with 60 additions and 15 deletions

View File

@@ -1,5 +1,4 @@
import Router from "koa-router";
import { find } from "lodash";
import { Client } from "@shared/types";
import { parseDomain } from "@shared/utils/domains";
import InviteAcceptedEmail from "@server/emails/templates/InviteAcceptedEmail";
@@ -59,18 +58,15 @@ router.post(
// If the user matches an email address associated with an SSO
// provider then just forward them directly to that sign-in page
if (user.authentications.length) {
const authProvider = find(team.authenticationProviders, {
id: user.authentications[0].authenticationProviderId,
});
if (authProvider?.enabled) {
ctx.body = {
redirect: `${team.url}/auth/${authProvider?.name}`,
};
return;
}
const authenticationProvider =
user.authentications[0].authenticationProvider;
ctx.body = {
redirect: `${team.url}/auth/${authenticationProvider?.name}`,
};
return;
}
// send email to users registered address with a short-lived token
// send email to users email address with a short-lived token
await SigninEmail.schedule({
to: user.email,
token: user.getEmailSigninToken(),