From b30dd0b2e96228b5e57a1b3c830fd8adff7ecc04 Mon Sep 17 00:00:00 2001 From: Hamza Alqurneh Date: Thu, 23 Jul 2026 13:00:42 +0300 Subject: [PATCH] Hide email/password login when Microsoft-only sign-in is enabled Login page shows only "Sign in with Microsoft" and the add-user form drops the password field when DisableEmailPasswordLogin is on. --- src/components/Login/index.tsx | 4 ++++ src/components/Settings/AddMemberModal.tsx | 11 +++++++---- src/types/config.ts | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Login/index.tsx b/src/components/Login/index.tsx index 359f1d8..7a483ea 100644 --- a/src/components/Login/index.tsx +++ b/src/components/Login/index.tsx @@ -6,10 +6,12 @@ import SignInWithMsButton from "src/components/Login/SignInWithMsButton"; import {ToastContainer} from "react-toastify"; import {BsFillEyeFill, BsFillEyeSlashFill} from "react-icons/bs"; import {useTypedSelector} from "src/state/ReduxSotre"; +import {useAppConfigQuery} from "src/client/apis/generalApi"; const Login = () => { const theme = useTypedSelector(i => i.theme) + const config = useAppConfigQuery() const {login} = useAuthApi(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); @@ -79,6 +81,7 @@ const Login = () => {
+ {!config.data?.disableEmailPasswordLogin && <>
+ } { error &&
diff --git a/src/components/Settings/AddMemberModal.tsx b/src/components/Settings/AddMemberModal.tsx index f261f12..1f0c7d5 100644 --- a/src/components/Settings/AddMemberModal.tsx +++ b/src/components/Settings/AddMemberModal.tsx @@ -5,6 +5,7 @@ import FormField from "src/components/common/forms/FormField"; import TextEditor from "src/components/common/forms/TextEditor"; import {apiClient} from "src/client"; import {ChoiceEditor} from "src/components/common/forms/ChoiceEditor"; +import {useAppConfigQuery} from "src/client/apis/generalApi"; function isValidEmail(email: string) { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; @@ -16,6 +17,8 @@ type Props = { } const AddMemberModal: React.FC = ({onClose}) => { + const config = useAppConfigQuery() + const disablePassword = Boolean(config.data?.disableEmailPasswordLogin) const [state, setState] = useState({name: "", email: "", password: "", role: 10}); const [errors, setErrors] = useState([]); const onSubmit = async () => { @@ -27,7 +30,7 @@ const AddMemberModal: React.FC = ({onClose}) => { if (state.name?.length < 3) { errors.push("Name must be longer than 3 characters") } - if (state.password?.length < 7) { + if (!disablePassword && state.password?.length < 7) { errors.push("Password must be longer than 8 characters") } if (errors.length > 0) { @@ -36,7 +39,7 @@ const AddMemberModal: React.FC = ({onClose}) => { } - const res = await apiClient.createMember(state) + const res = await apiClient.createMember(disablePassword ? {...state, password: ""} : state) if (res.succeeded) { onClose() } @@ -57,13 +60,13 @@ const AddMemberModal: React.FC = ({onClose}) => {
-
+ {!disablePassword &&
setState((s) => ({...s, password: e}))}/> -
+
}
e.title} optionValue={(e) => e.id} options={RolesSelection} diff --git a/src/types/config.ts b/src/types/config.ts index f50f514..a9ba173 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -19,5 +19,6 @@ export type Config = { msalClientId: string | null, msalRedirectUri: string | null, msalTenantId: string | null, + disableEmailPasswordLogin: boolean, isRabbitMqManagementConfigured: boolean }