Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix: persist setup credentials for first-run wizard. Related to #1110

rcourtman884ede22f15b
diff --git a/frontend-modern/src/components/Login.tsx b/frontend-modern/src/components/Login.tsx
index 0967c1110a..2973126741 100644
--- a/frontend-modern/src/components/Login.tsx
+++ b/frontend-modern/src/components/Login.tsx
@@ -288,9 +288,18 @@ export const Login: Component<LoginProps> = (props) => {
authStatus: authStatus(),
});
+ const hasStoredSetupCredentials = () => {
+ if (typeof window === 'undefined') return false;
+ try {
+ return Boolean(sessionStorage.getItem(STORAGE_KEYS.SETUP_CREDENTIALS));
+ } catch (_err) {
+ return false;
+ }
+ };
+
const legacyDisableAuth = () => authStatus()?.deprecatedDisableAuth === true;
const showFirstRunSetup = () =>
- authStatus()?.hasAuthentication === false || legacyDisableAuth();
+ authStatus()?.hasAuthentication === false || legacyDisableAuth() || hasStoredSetupCredentials();
const shouldShowLocalLogin = () => {
const params = new URLSearchParams(window.location.search);
diff --git a/frontend-modern/src/components/SetupWizard/SetupWizard.tsx b/frontend-modern/src/components/SetupWizard/SetupWizard.tsx
index 26510a71ff..c6cbacb877 100644
--- a/frontend-modern/src/components/SetupWizard/SetupWizard.tsx
+++ b/frontend-modern/src/components/SetupWizard/SetupWizard.tsx
@@ -3,6 +3,7 @@ import { WelcomeStep } from './steps/WelcomeStep';
import { SecurityStep } from './steps/SecurityStep';
import { CompleteStep } from './steps/CompleteStep';
import { StepIndicator } from './StepIndicator';
+import { STORAGE_KEYS } from '@/utils/localStorage';
export type WizardStep = 'welcome' | 'security' | 'complete';
@@ -26,8 +27,7 @@ interface SetupWizardProps {
}
export const SetupWizard: Component<SetupWizardProps> = (props) => {
- const [currentStep, setCurrentStep] = createSignal<WizardStep>('welcome');
- const [wizardState, setWizardState] = createSignal<WizardState>({
+ const defaultWizardState: WizardState = {
username: 'admin',
password: '',
apiToken: '',
@@ -35,9 +35,39 @@ export const SetupWizard: Component<SetupWizardProps> = (props) => {
nodeName: '',
aiEnabled: false,
autoUpdatesEnabled: true,
- });
+ };
+
+ const loadStoredCredentials = (): WizardState | null => {
+ if (typeof window === 'undefined') return null;
+ try {
+ const raw = sessionStorage.getItem(STORAGE_KEYS.SETUP_CREDENTIALS);
+ if (!raw) return null;
+ const parsed = JSON.parse(raw) as Partial<WizardState>;
+ if (!parsed.username || !parsed.password || !parsed.apiToken) {
+ sessionStorage.removeItem(STORAGE_KEYS.SETUP_CREDENTIALS);
+ return null;
+ }
+ return {
+ ...defaultWizardState,
+ username: parsed.username,
+ password: parsed.password,
+ apiToken: parsed.apiToken,
+ };
+ } catch (_err) {
+ try {
+ sessionStorage.removeItem(STORAGE_KEYS.SETUP_CREDENTIALS);
+ } catch (_removeErr) {
+ // Ignore cleanup errors
+ }
+ return null;
+ }
+ };
+
+ const storedCredentials = loadStoredCredentials();
+ const [currentStep, setCurrentStep] = createSignal<WizardStep>(storedCredentials ? 'complete' : 'welcome');
+ const [wizardState, setWizardState] = createSignal<WizardState>(storedCredentials ?? defaultWizardState);
const [bootstrapToken, setBootstrapToken] = createSignal(props.bootstrapToken || '');
- const [isUnlocked, setIsUnlocked] = createSignal(props.isUnlocked || false);
+ const [isUnlocked, setIsUnlocked] = createSignal(props.isUnlocked || Boolean(storedCredentials));
const steps: WizardStep[] = ['welcome', 'security', 'complete'];
@@ -61,6 +91,20 @@ export const SetupWizard: Component<SetupWizardProps> = (props) => {
setWizardState(prev => ({ ...prev, ...updates }));
};
+ const clearStoredCredentials = () => {
+ if (typeof window === 'undefined') return;
+ try {
+ sessionStorage.removeItem(STORAGE_KEYS.SETUP_CREDENTIALS);
+ } catch (_err) {
+ // Ignore storage errors
+ }
+ };
+
+ const handleComplete = () => {
+ clearStoredCredentials();
+ props.onComplete();
+ };
+
return (
<div
class="min-h-screen bg-gradient-to-br from-slate-900 via-blue-900 to-indigo-900 flex flex-col"
@@ -110,7 +154,7 @@ export const SetupWizard: Component<SetupWizardProps> = (props) => {
<Show when={currentStep() === 'complete'}>
<CompleteStep
state={wizardState()}
- onComplete={props.onComplete}
+ onComplete={handleComplete}
/>
</Show>
</div>
diff --git a/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx b/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx
index 5e120fbe77..9691d01ec5 100644
--- a/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx
+++ b/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx
@@ -1,6 +1,7 @@
import { Component, createSignal, Show } from 'solid-js';
import { showError, showSuccess } from '@/utils/toast';
import { setApiToken as setApiClientToken, apiFetchJSON } from '@/utils/apiClient';
+import { STORAGE_KEYS } from '@/utils/localStorage';
import type { WizardState } from '../SetupWizard';
interface SecurityStepProps {
@@ -72,6 +73,22 @@ export const SecurityStep: Component<SecurityStepProps> = (props) => {
apiToken: token,
});
+ if (typeof window !== 'undefined') {
+ try {
+ sessionStorage.setItem(
+ STORAGE_KEYS.SETUP_CREDENTIALS,
+ JSON.stringify({
+ username: username(),
+ password: finalPassword,
+ apiToken: token,
+ createdAt: new Date().toISOString(),
+ }),
+ );
+ } catch (_err) {
+ // Ignore storage errors (private browsing, quota limits, etc.)
+ }
+ }
+
showSuccess('Security configured!');
props.onNext();
} catch (error) {
diff --git a/frontend-modern/src/utils/localStorage.ts b/frontend-modern/src/utils/localStorage.ts
index 03ea2cfd81..2257015c1f 100644
--- a/frontend-modern/src/utils/localStorage.ts
+++ b/frontend-modern/src/utils/localStorage.ts
@@ -97,6 +97,7 @@ export const STORAGE_KEYS = {
// Authentication
AUTH: 'pulse_auth',
LEGACY_TOKEN: 'pulse_api_token',
+ SETUP_CREDENTIALS: 'pulse_setup_credentials',
// UI preferences
DARK_MODE: 'darkMode',