diff --git a/src/defaultOptions.ts b/src/defaultOptions.ts index 361879be..85ebae17 100644 --- a/src/defaultOptions.ts +++ b/src/defaultOptions.ts @@ -84,6 +84,7 @@ export const defaultOptions = { localServerOptions: { gameMode: 1 } as any, + saveLoginPassword: 'prompt' as 'prompt' | 'never' | 'always', preferLoadReadonly: false, experimentalClientSelfReload: false, remoteSoundsSupport: false, diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index b03db37d..a47c06eb 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -550,6 +550,16 @@ export const guiOptionsScheme: { return Server Connection }, }, + { + saveLoginPassword: { + tooltip: 'Controls whether to save login passwords for servers in this browser memory.', + values: [ + 'prompt', + 'always', + 'never' + ] + }, + }, { custom () { const { serversAutoVersionSelect } = useSnapshot(options) diff --git a/src/react/ChatProvider.tsx b/src/react/ChatProvider.tsx index 0bb13285..066bc48a 100644 --- a/src/react/ChatProvider.tsx +++ b/src/react/ChatProvider.tsx @@ -73,16 +73,28 @@ export default () => { } const builtinHandled = tryHandleBuiltinCommand(message) - if (getServerIndex() !== undefined && (message.startsWith('/login') || message.startsWith('/register'))) { - showNotification('Click here to save your password in browser for auto-login', undefined, false, undefined, () => { + if (getServerIndex() !== undefined && (message.startsWith('/login') || message.startsWith('/register')) && options.saveLoginPassword !== 'never') { + const savePassword = () => { + let hadPassword = false updateLoadedServerData((server) => { server.autoLogin ??= {} const password = message.split(' ')[1] + hadPassword = !!server.autoLogin[bot.username] server.autoLogin[bot.username] = password return { ...server } }) - hideNotification() - }) + if (options.saveLoginPassword === 'always') { + const message = hadPassword ? 'Password updated in browser for auto-login' : 'Password saved in browser for auto-login' + showNotification(message, undefined, false, undefined) + } else { + hideNotification() + } + } + if (options.saveLoginPassword === 'prompt') { + showNotification('Click here to save your password in browser for auto-login', undefined, false, undefined, savePassword) + } else { + savePassword() + } notificationProxy.id = 'auto-login' const listener = () => { hideNotification()