Prevent basic auth with both empty username and password

On ios the native basic auth prompt does not work with both an empty username and password.
In case both are empty, the "login" button is disabled and can't be pressed.
This commit is contained in:
schroda
2025-06-28 03:28:00 +02:00
parent 1a2a1b3897
commit fd89d80217

View File

@@ -285,18 +285,21 @@ export const ServerSettings = () => {
<Switch <Switch
edge="end" edge="end"
checked={serverSettings.basicAuthEnabled} checked={serverSettings.basicAuthEnabled}
disabled={!serverSettings.basicAuthUsername.trim() && !serverSettings.basicAuthPassword.trim()}
onChange={(e) => updateSetting('basicAuthEnabled', e.target.checked)} onChange={(e) => updateSetting('basicAuthEnabled', e.target.checked)}
/> />
</ListItem> </ListItem>
<TextSetting <TextSetting
settingName={t('settings.server.auth.basic.label.username')} settingName={t('settings.server.auth.basic.label.username')}
value={serverSettings.basicAuthUsername} value={serverSettings.basicAuthUsername}
validate={(value) => !serverSettings.basicAuthEnabled || !!value.trim()}
handleChange={(authUsername) => updateSetting('basicAuthUsername', authUsername)} handleChange={(authUsername) => updateSetting('basicAuthUsername', authUsername)}
/> />
<TextSetting <TextSetting
settingName={t('settings.server.auth.basic.label.password')} settingName={t('settings.server.auth.basic.label.password')}
value={serverSettings.basicAuthPassword} value={serverSettings.basicAuthPassword}
isPassword isPassword
validate={(value) => !serverSettings.basicAuthEnabled || !!value.trim()}
handleChange={(authPassword) => updateSetting('basicAuthPassword', authPassword)} handleChange={(authPassword) => updateSetting('basicAuthPassword', authPassword)}
/> />
</List> </List>