update: disable password login when not supported
This commit is contained in:
parent
786598b4eb
commit
46981d4677
@ -78,6 +78,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [supportPassAuth, setSupportPassAuth] = useState(true);
|
||||||
const [ssoBaseUrl, setSSOBaseUrl] = useState("");
|
const [ssoBaseUrl, setSSOBaseUrl] = useState("");
|
||||||
let locale = useLocale();
|
let locale = useLocale();
|
||||||
const setLocale = useSetLocale();
|
const setLocale = useSetLocale();
|
||||||
@ -231,17 +232,21 @@ const LoginPage = ({ theme }) => {
|
|||||||
|
|
||||||
// setSSOUrl
|
// setSSOUrl
|
||||||
const authMethodUrl = `${formData.base_url}/_matrix/client/r0/login`;
|
const authMethodUrl = `${formData.base_url}/_matrix/client/r0/login`;
|
||||||
let supportSSO = false;
|
let supportPass = false, supportSSO = false;
|
||||||
fetchUtils
|
fetchUtils
|
||||||
.fetchJson(authMethodUrl, { method: "GET" })
|
.fetchJson(authMethodUrl, { method: "GET" })
|
||||||
.then(({ json }) => {
|
.then(({ json }) => {
|
||||||
json.flows.forEach(f => {
|
json.flows.forEach(f => {
|
||||||
if (f.type === 'm.login.sso') {
|
if (f.type === 'm.login.password') {
|
||||||
setSSOBaseUrl(formData.base_url);
|
supportPass = true;
|
||||||
|
} else if (f.type === 'm.login.sso') {
|
||||||
supportSSO = true;
|
supportSSO = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!supportSSO) {
|
setSupportPassAuth(supportPass);
|
||||||
|
if (supportSSO) {
|
||||||
|
setSSOBaseUrl(formData.base_url);
|
||||||
|
} else {
|
||||||
setSSOBaseUrl("");
|
setSSOBaseUrl("");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -260,7 +265,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
name="username"
|
name="username"
|
||||||
component={renderInput}
|
component={renderInput}
|
||||||
label={translate("ra.auth.username")}
|
label={translate("ra.auth.username")}
|
||||||
disabled={loading}
|
disabled={loading || !supportPassAuth}
|
||||||
onBlur={handleUsernameChange}
|
onBlur={handleUsernameChange}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
@ -271,7 +276,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
component={renderInput}
|
component={renderInput}
|
||||||
label={translate("ra.auth.password")}
|
label={translate("ra.auth.password")}
|
||||||
type="password"
|
type="password"
|
||||||
disabled={loading}
|
disabled={loading || !supportPassAuth}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -330,7 +335,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
type="submit"
|
type="submit"
|
||||||
color="primary"
|
color="primary"
|
||||||
disabled={loading}
|
disabled={loading || !supportPassAuth}
|
||||||
className={classes.button}
|
className={classes.button}
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user