diff options
Diffstat (limited to 'packages/meshbay-hub/src')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/app.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js index ee0ab07..87c4e33 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/app.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/app.js @@ -668,6 +668,15 @@ function App() { const route = useRoute(); const [theme, setTheme] = useState(getInitialTheme); const [user, setUser] = useState(loadAuth); + // Signed in, on the sign-in or sign-up form. A session restored under a + // `#/login` still in the address bar drew the login form, prefilled by the + // browser, beneath a navigation bar already showing the account. Home instead, + // with `replace` so Back does not lead to the form again. Not `#/reset`: that + // flow signs in half-way and still has its progress and result to show. + const onAuthForm = route === '/login' || route === '/register'; + useEffect(() => { + if (user && onAuthForm) window.location.replace('#/'); + }, [user, onAuthForm]); // A desktop build with a remembered device signs in without asking. Null // until it has tried, so nothing renders a sign-in form the user is about to // be taken past. @@ -1007,7 +1016,7 @@ function App() { // Signing in with this device's key. Showing a form here would be showing // one the user is about to be taken past. page = html`<p class="page-message">${t('status.connecting')}</p>`; - } else if (route === '/login' || route === '/register' || route === '/reset') { + } else if ((onAuthForm && !user) || route === '/reset') { page = route === '/register' ? html`<${RegisterPage} />` : route === '/reset' |