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

View File

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