fix: login creates corpus token immediately
This commit is contained in:
parent
95abf5c808
commit
6c0f5077a6
@ -908,6 +908,13 @@ async function handleLogin() {
|
|||||||
showLoggedIn(d.username);
|
showLoggedIn(d.username);
|
||||||
if (d.is_admin) document.getElementById('gen-code-btn').style.display = '';
|
if (d.is_admin) document.getElementById('gen-code-btn').style.display = '';
|
||||||
document.getElementById('login-pass').value = '';
|
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 {
|
} else {
|
||||||
showLoginErr(d.error || '登录失败');
|
showLoginErr(d.error || '登录失败');
|
||||||
}
|
}
|
||||||
@ -944,8 +951,10 @@ function logout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function goToRepo() {
|
function goToRepo() {
|
||||||
|
// 首页登录不传Forgejo会话,跳转到Forgejo登录(带仓库重定向)
|
||||||
const u = localStorage.getItem('current_user');
|
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() {
|
function toggleLogin() {
|
||||||
@ -1057,4 +1066,4 @@ async function sendMessage() {
|
|||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user