2022-03-02 18:18:50 +00:00
|
|
|
import { getAppsmithConfigs } from "@appsmith/configs";
|
|
|
|
|
const {
|
|
|
|
|
disableLoginForm,
|
|
|
|
|
enableGithubOAuth,
|
|
|
|
|
enableGoogleOAuth,
|
|
|
|
|
} = getAppsmithConfigs();
|
|
|
|
|
|
|
|
|
|
export const connectedMethods = [
|
|
|
|
|
enableGoogleOAuth,
|
|
|
|
|
enableGithubOAuth,
|
|
|
|
|
!disableLoginForm,
|
|
|
|
|
].filter(Boolean);
|
|
|
|
|
|
2022-03-04 06:26:12 +00:00
|
|
|
/* settings is the updated & unsaved settings on Admin settings page */
|
2022-03-02 18:18:50 +00:00
|
|
|
export const saveAllowed = (settings: any) => {
|
2022-03-04 06:26:12 +00:00
|
|
|
if (connectedMethods.length === 1) {
|
|
|
|
|
const checkFormLogin = !(
|
|
|
|
|
"APPSMITH_FORM_LOGIN_DISABLED" in settings || disableLoginForm
|
|
|
|
|
),
|
|
|
|
|
checkGoogleAuth =
|
|
|
|
|
settings["APPSMITH_OAUTH2_GOOGLE_CLIENT_ID"] !== "" &&
|
|
|
|
|
enableGoogleOAuth,
|
|
|
|
|
checkGithubAuth =
|
|
|
|
|
settings["APPSMITH_OAUTH2_GITHUB_CLIENT_ID"] !== "" &&
|
|
|
|
|
enableGithubOAuth;
|
|
|
|
|
|
|
|
|
|
return checkFormLogin || checkGoogleAuth || checkGithubAuth;
|
2022-03-02 18:18:50 +00:00
|
|
|
} else {
|
2022-03-04 06:26:12 +00:00
|
|
|
return connectedMethods.length >= 2;
|
2022-03-02 18:18:50 +00:00
|
|
|
}
|
|
|
|
|
};
|