diff --git a/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx b/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx index 7000dddc3..5842a3108 100644 --- a/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx +++ b/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx @@ -14,6 +14,10 @@ export const QuickSecuritySetup: Component = () => { const [copied, setCopied] = createSignal<'username' | 'password' | 'token' | null>(null); const [readyToRestart, setReadyToRestart] = createSignal(false); const [isRestarting, setIsRestarting] = createSignal(false); + const [useCustomPassword, setUseCustomPassword] = createSignal(false); + const [customUsername, setCustomUsername] = createSignal('admin'); + const [customPassword, setCustomPassword] = createSignal(''); + const [confirmPassword, setConfirmPassword] = createSignal(''); const generatePassword = (length: number = 16): string => { // Avoid special chars that could cause issues with URLs or shell commands @@ -72,13 +76,25 @@ export const QuickSecuritySetup: Component = () => { }; const setupSecurity = async () => { + // Validate custom password if using + if (useCustomPassword()) { + if (customPassword().length < 8) { + showError('Password must be at least 8 characters'); + return; + } + if (customPassword() !== confirmPassword()) { + showError('Passwords do not match'); + return; + } + } + setIsSettingUp(true); try { - // Generate credentials + // Generate or use custom credentials const newCredentials: SecurityCredentials = { - username: 'admin', - password: generatePassword(), + username: customUsername(), + password: useCustomPassword() ? customPassword() : generatePassword(), apiToken: generateToken() }; @@ -188,6 +204,83 @@ Important: +
+
+ +
+ + +
+
+ + +
+
+ + setCustomUsername(e.currentTarget.value)} + class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent" + placeholder="admin" + /> +
+
+ + setCustomPassword(e.currentTarget.value)} + class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent" + placeholder="Enter password" + /> +
+
+ + setConfirmPassword(e.currentTarget.value)} + class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent" + placeholder="Confirm password" + /> +
+
+
+ + +

+ A secure 16-character password will be generated for you +

+
+
+
@@ -195,7 +288,9 @@ Important:

Important:

-

Credentials will be shown only once. Save them immediately!

+

{useCustomPassword() + ? 'Your password will be hashed before storage' + : 'Credentials will be shown only once. Save them immediately!'}