fix: login creates corpus token immediately

This commit is contained in:
root 2026-05-22 15:39:32 +08:00
parent 95abf5c808
commit 6c0f5077a6

View File

@ -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() {
</body>
</html>
</html>