fix: sso templates (#1753)

This commit is contained in:
boojack 2023-05-26 22:25:30 +08:00 committed by GitHub
parent dbe8aa1d3a
commit ec26a9702d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,14 +8,7 @@ import { generateDialog } from "./Dialog";
import Icon from "./Icon";
import { useTranslation } from "react-i18next";
interface Props extends DialogProps {
identityProvider?: IdentityProvider;
confirmCallback?: () => void;
}
const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
const { t } = useTranslation();
const templateList: IdentityProvider[] = [
const templateList: IdentityProvider[] = [
{
id: UNKNOWN_ID,
name: "GitHub",
@ -30,9 +23,9 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
userInfoUrl: "https://api.github.com/user",
scopes: ["user"],
fieldMapping: {
identifier: t("setting.sso-section.identifier"),
displayName: "",
email: "",
identifier: "login",
displayName: "name",
email: "email",
},
},
},
@ -51,9 +44,9 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
userInfoUrl: "https://gitlab.com/oauth/userinfo",
scopes: ["openid"],
fieldMapping: {
identifier: t("setting.sso-section.identifier"),
displayName: "",
email: "",
identifier: "name",
displayName: "name",
email: "email",
},
},
},
@ -72,16 +65,16 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
scopes: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"],
fieldMapping: {
identifier: t("setting.sso-section.identifier"),
displayName: "",
email: "",
identifier: "email",
displayName: "name",
email: "email",
},
},
},
},
{
id: UNKNOWN_ID,
name: t("setting.sso-section.custom"),
name: "Custom",
type: "OAUTH2",
identifierFilter: "",
config: {
@ -100,7 +93,15 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
},
},
},
];
];
interface Props extends DialogProps {
identityProvider?: IdentityProvider;
confirmCallback?: () => void;
}
const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
const { t } = useTranslation();
const identityProviderTypes = [...new Set(templateList.map((t) => t.type))];
const { confirmCallback, destroy, identityProvider } = props;
const [basicInfo, setBasicInfo] = useState({