Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: allow persistent dismissal of password check failures
[._.]/ Adam Eivy4072014b6891
diff --git a/client/src/components/PasswordRiskWarning.jsx b/client/src/components/PasswordRiskWarning.jsxindex f8e21cf7a1..9cf0f816f3 100644--- a/client/src/components/PasswordRiskWarning.jsx+++ b/client/src/components/PasswordRiskWarning.jsx@@ -1,27 +1,40 @@import { useCallback, useEffect, useRef, useState } from 'react';import { Link, useLocation } from 'react-router';-import { getPasswordRiskStatus } from '../services/apiAuth.js';+import { getAuthStatus, getPasswordRiskStatus } from '../services/apiAuth.js';import { safeReadStorage, safeWriteStorage, safeRemoveStorage } from '../lib/safeStorage.js';import Modal from './ui/Modal.jsx';const ACKNOWLEDGEMENT_KEY = 'portos-password-risk-v1';+const CHECK_DISMISSED_KEY = 'portos-password-check-dismissed-v1';export default function PasswordRiskWarning() {const { pathname } = useLocation();const [status, setStatus] = useState(null);const [error, setError] = useState('');+ const [checkDismissed, setCheckDismissed] = useState(() => safeReadStorage(CHECK_DISMISSED_KEY) === 'true');const [accepted, setAccepted] = useState(false);const [acknowledgedRevision, setAcknowledgedRevision] = useState(null);const generation = useRef(0);const load = useCallback(() => {const current = ++generation.current;- getPasswordRiskStatus({ silent: true }).then((value) => {+ const showCheckError = async () => {+ // Older servers and transient failures may make the risk endpoint unavailable.+ // The login gate's public endpoint can still confirm password protection.+ const auth = await getAuthStatus({ silent: true }).catch(() => null);if (current !== generation.current) return;- if (typeof value?.enabled !== 'boolean' || typeof value?.revision !== 'string' || !value.revision) {- setStatus(null);- setError('PortOS could not confirm password protection. Check Security settings or retry.');+ if (auth?.enabled === true) {+ setStatus({ enabled: true });+ setError('');return;}+ setStatus(null);+ setError('PortOS could not confirm password protection. Check Security settings or retry.');+ };+ getPasswordRiskStatus({ silent: true }).then((value) => {+ if (current !== generation.current) return;+ if (typeof value?.enabled !== 'boolean' || (value.enabled === false && (typeof value?.revision !== 'string' || !value.revision))) {+ return showCheckError();+ }if (value.enabled) safeRemoveStorage(ACKNOWLEDGEMENT_KEY);setAcknowledgedRevision(value.enabled ? null : safeReadStorage(ACKNOWLEDGEMENT_KEY));setAccepted(false);@@ -29,8 +42,7 @@ export default function PasswordRiskWarning() {setError('');}).catch(() => {if (current !== generation.current) return;- setStatus(null);- setError('PortOS could not confirm password protection. Check Security settings or retry.');+ return showCheckError();});}, []);@@ -45,6 +57,11 @@ export default function PasswordRiskWarning() {};}, [load, pathname]);+ const dismissCheck = () => {+ safeWriteStorage(CHECK_DISMISSED_KEY, 'true');+ setCheckDismissed(true);+ };+const acknowledge = () => {if (!accepted || status?.enabled !== false) return;safeWriteStorage(ACKNOWLEDGEMENT_KEY, status.revision);@@ -61,7 +78,7 @@ export default function PasswordRiskWarning() {// Leaving this route rechecks server state; a failed/cancelled setup warns again.if (pathname === '/settings/security') return null;const required = status?.enabled === false && acknowledgedRevision !== status.revision;- if (!required && !error) return null;+ if (!required && (!error || checkDismissed)) return null;return (<Modal open closeOnEsc={false} closeOnBackdrop={false} usePortal ariaLabelledBy="password-risk-title"panelClassName="bg-port-card border border-port-warning rounded-lg p-5 space-y-4">@@ -70,7 +87,7 @@ export default function PasswordRiskWarning() {</h2><p>PortOS can run commands and read or change files on this computer. Without a password, any device that can reach its APIs may gain that access, including a compromised machine on your LAN or Tailscale network.</p><p>Set a strong, unique PortOS password to reduce this risk. Keep PortOS on your private network: a password does not make public internet exposure through Cloudflare tunnels, gateways, or port forwarding safe.</p>- <p>Risk acceptance applies only to this browser. Other browsers will ask separately.</p>+ <p>{required ? 'Risk acceptance applies only to this browser. Other browsers will ask separately.' : 'Dismissing this check is saved in this browser. A confirmed missing password will still show a risk warning.'}</p>{error && <p role="alert" className="text-port-error">{error}</p>}{required && <label htmlFor="password-risk-accept" className="flex items-start gap-3"><input id="password-risk-accept" type="checkbox" checked={accepted}@@ -83,6 +100,7 @@ export default function PasswordRiskWarning() {className="min-h-11 px-4 py-2 border border-port-border rounded disabled:opacity-50">Accept risk and dismiss</button>}+ {!required && <button type="button" onClick={dismissCheck} className="min-h-11 px-4 py-2 border border-port-border rounded">Dismiss and don’t show again</button>}{error && <button type="button" onClick={load} className="min-h-11 px-4 py-2 border border-port-border rounded">Retry</button>}</div></Modal>diff --git a/client/src/components/PasswordRiskWarning.test.jsx b/client/src/components/PasswordRiskWarning.test.jsxindex 1e0825cc84..6420cb8915 100644--- a/client/src/components/PasswordRiskWarning.test.jsx+++ b/client/src/components/PasswordRiskWarning.test.jsx@@ -2,13 +2,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';import { Link, MemoryRouter } from 'react-router';import PasswordRiskWarning from './PasswordRiskWarning.jsx';-import { getPasswordRiskStatus } from '../services/apiAuth.js';+import { getAuthStatus, getPasswordRiskStatus } from '../services/apiAuth.js';-vi.mock('../services/apiAuth.js', () => ({ getPasswordRiskStatus: vi.fn() }));-const renderWarning = () => render(<MemoryRouter><PasswordRiskWarning /><Link to="/">Home</Link></MemoryRouter>);+vi.mock('../services/apiAuth.js', () => ({ getAuthStatus: vi.fn(), getPasswordRiskStatus: vi.fn() }));+const renderWarning = () => render(<MemoryRouter><PasswordRiskWarning /><Link to="/">Home</Link><Link to="/apps">Apps</Link></MemoryRouter>);beforeEach(() => {vi.resetAllMocks();localStorage.clear();+ getAuthStatus.mockResolvedValue({ enabled: false });getPasswordRiskStatus.mockResolvedValue({ enabled: false, revision: 'initial' });});afterEach(() => { cleanup(); vi.restoreAllMocks(); });@@ -75,6 +76,32 @@ describe('password risk warning', () => {expect(screen.queryByRole('dialog')).not.toBeInTheDocument();});+ it('uses public auth status when the risk endpoint is unavailable on a protected instance', async () => {+ getPasswordRiskStatus.mockRejectedValue(new Error('unavailable'));+ getAuthStatus.mockResolvedValue({ enabled: true });+ renderWarning();+ await waitFor(() => expect(getAuthStatus).toHaveBeenCalledWith({ silent: true }));+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();+ });++ it('persists check-error dismissal across focus, navigation and remount without accepting known risk', async () => {+ getPasswordRiskStatus.mockResolvedValue({ unexpected: true });+ renderWarning();+ fireEvent.click(await screen.findByRole('button', { name: 'Dismiss and don’t show again' }));+ fireEvent(window, new Event('focus'));+ await waitFor(() => expect(getAuthStatus).toHaveBeenCalledTimes(2));+ fireEvent.click(screen.getByRole('link', { name: 'Apps' }));+ await waitFor(() => expect(getAuthStatus).toHaveBeenCalledTimes(3));+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();+ cleanup();+ renderWarning();+ await waitFor(() => expect(getAuthStatus).toHaveBeenCalledTimes(4));+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();+ getPasswordRiskStatus.mockResolvedValue({ enabled: false, revision: 'initial' });+ fireEvent(window, new Event('portos:auth-changed'));+ expect(await screen.findByRole('checkbox')).toBeInTheDocument();+ });+it('shows a recoverable status error without offering risk acceptance on an unknown status', async () => {getPasswordRiskStatus.mockRejectedValueOnce(new Error('offline'));renderWarning();