From 6c0f5077a6a1f1d0770f17ce4c0a834bbfe7a7b5 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 May 2026 15:39:32 +0800 Subject: [PATCH] fix: login creates corpus token immediately --- homepage/index.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/homepage/index.html b/homepage/index.html index f005ccd..4005dcc 100644 --- a/homepage/index.html +++ b/homepage/index.html @@ -908,6 +908,13 @@ async function handleLogin() { showLoggedIn(d.username); if (d.is_admin) document.getElementById('gen-code-btn').style.display = ''; document.getElementById('login-pass').value = ''; + // 登录成功即创建所有模块通行证 + fetch('/api/auth/quick-login?username=' + encodeURIComponent(d.username)) + .then(function(r) { return r.json(); }) + .then(function(d2) { + if (d2.token) localStorage.setItem('corpus_token', d2.token); + }) + .catch(function() {}); } else { showLoginErr(d.error || '登录失败'); } @@ -944,8 +951,10 @@ function logout() { } function goToRepo() { + // 首页登录不传Forgejo会话,跳转到Forgejo登录(带仓库重定向) const u = localStorage.getItem('current_user'); - if (u) window.location.href = '/code/' + u; + if (u) window.location.href = "/code/user/login?redirect_to=/code/" + encodeURIComponent(u) + "/guanghulab"; + else window.location.href = '/code/user/login'; } function toggleLogin() { @@ -1057,4 +1066,4 @@ async function sendMessage() { - + \ No newline at end of file