fix: QQ Login Check

This commit is contained in:
手瓜一十雪
2024-05-08 20:54:43 +08:00
parent 19afb4941b
commit 3268fc1014
2 changed files with 7 additions and 9 deletions

View File

@@ -13,14 +13,15 @@ export async function AuthApi(req: Request, res: Response, next: NextFunction) {
next();
return;
}
if (req.headers?.authorization) {
let token = req.headers?.authorization.split(' ')[1];
if (req.headers.authorization) {
let token = req.headers.authorization.split(' ')[1];
let Credential = JSON.parse(Buffer.from(token, 'base64').toString('utf-8'));
let config = await WebUiConfig.GetWebUIConfig();
let credentialJson = await AuthHelper.validateCredentialWithinOneHour(config.token, Credential);
if (credentialJson) {
//通过验证
next();
return;
}
res.json({
code: -1,
@@ -29,10 +30,7 @@ export async function AuthApi(req: Request, res: Response, next: NextFunction) {
return;
}
} catch (e: any) {
res.json({
code: -1,
msg: 'Server Error',
});
console.log(e);
return;
}
res.json({

View File

@@ -252,8 +252,8 @@
optionUinEle.value = QuickUin;
QuickListSelect.appendChild(optionUinEle);
});
generateQrCode(await GetQQLoginQrcode(), document.querySelector('#qrcode-canvas'));
setTimeout(HeartBeat, 3000);
generateQrCode(await GetQQLoginQrcode(localStorage.getItem('auth')), document.querySelector('#qrcode-canvas'));
setInterval(HeartBeat, 3000);
}
document.getElementById('quick-login').addEventListener('click', function () {
let quickLoginOptions = document.querySelector('#quick-login-dropdown');
@@ -272,7 +272,7 @@
alert("登录失败," + errMsg);
}
//await (localStorage.getItem('auth'))
document.getElementById('quick-login-options').classList.remove('show');
//document.getElementById('quick-login-options').classList.remove('show');
}
document.getElementById('qrcode-login').addEventListener('click', function () {
let loginForm = document.querySelector('#quick-login-dropdown');