diff --git a/public/s/js/anon_ssh.js b/public/s/js/anon_ssh.js index 6d6549c..426632a 100644 --- a/public/s/js/anon_ssh.js +++ b/public/s/js/anon_ssh.js @@ -765,6 +765,7 @@ * Explicitly log in as anonymous (generates identity if none, establishes session, syncs guest favs) */ async loginAsAnonymous() { + if (this._loginInProgress) return; if (window.f0ckSession && window.f0ckSession.enable_anonymous_access === false) { return; } @@ -780,14 +781,22 @@ return; } + this._loginInProgress = true; + + // Close the login modal immediately for visual feedback + const loginModal = document.getElementById('login-modal'); + if (loginModal) loginModal.style.display = 'none'; + try { if (!this.pubkey) { - await this.generateIdentity(true); - } else { - await this.ensureSession(true, true); + await this.generateIdentity(); } + await this.ensureSession(true, true); - if (!this.isSessionReady) return; + if (!this.isSessionReady) { + this._loginInProgress = false; + return; + } // Sync any guest favorites saved in localStorage to this anon account if (window.f0ckGuestFavs && typeof window.f0ckGuestFavs.importToAccount === 'function') { @@ -800,6 +809,7 @@ // Reload page to reflect authenticated anonymous session across navbar, comments, settings window.location.reload(); } catch (err) { + this._loginInProgress = false; console.error('[ANON_SSH] Login as anonymous failed:', err); alert('Failed to log in as anonymous: ' + (err.message || err)); } @@ -977,6 +987,16 @@ } attachUIListeners() { + // Direct click handler for the modal login-as-anonymous button + const modalAnonBtn = document.getElementById('modal-login-as-anon-btn'); + if (modalAnonBtn) { + modalAnonBtn.addEventListener('click', (e) => { + e.preventDefault(); + e.stopPropagation(); + this.loginAsAnonymous(); + }); + } + // Global click handler for Login as anonymous, Identity modal, & Logout document.addEventListener('click', (e) => { const identityTarget = e.target.closest('#nav-anon-identity-btn'); diff --git a/src/inc/locales/en.json b/src/inc/locales/en.json index 3ff9d80..30460fa 100644 --- a/src/inc/locales/en.json +++ b/src/inc/locales/en.json @@ -43,7 +43,7 @@ "url_tab_yt": "URL / YouTube", "url_placeholder": "Paste a URL to download...", "url_placeholder_yt": "Paste a URL or YouTube link...", - "url_placeholder_shitpost": "Paste multiple URLs here (one per line)...", + "url_placeholder_shitpost": "Paste a URL or YouTube link...", "drop_here": "Drop your file here", "admin_boost": "Admin Boost", "custom_thumbnail": "Custom Thumbnail", diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index e76df37..1f0f750 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -13,10 +13,15 @@ const auth = async (req, res, next) => { }; export default (router, tpl) => { - router.get(/\/user\/(?[^/]+)\/?$/, async (req, res) => { + router.get(/^\/user\/(?[^/]+)\/?$/, async (req, res) => { // When anonymization is active, user profiles must not be accessible without an authenticated regular session + // But allow anon users to view their own profile if (isAnonymizeSession(req.session)) { - return req.session ? res.redirect('/') : res.redirect('/login'); + const requestedUser = decodeURIComponent(req.params.user).toLowerCase(); + const sessionUser = (req.session?.user || req.session?.login || '').toLowerCase(); + if (requestedUser !== sessionUser) { + return req.session ? res.redirect('/') : res.redirect('/login'); + } } const user = decodeURIComponent(req.params.user); const mime = req.cookies.mime !== undefined ? req.cookies.mime : (req.query?.mime || req.url.qs?.mime || null); diff --git a/views/scroller.html b/views/scroller.html index e6a6b9e..e2194d7 100644 --- a/views/scroller.html +++ b/views/scroller.html @@ -1065,7 +1065,9 @@ + @if(typeof session !== 'undefined' && session && (!session.is_anon || (enable_anonymous_access && anon_permissions.filter))) + @endif @if(typeof session !== 'undefined' && session)
@@ -290,7 +285,7 @@ {{ t('nav.favs') }} @endif @if(enable_anonymous_access) - + @endif