修复bug

This commit is contained in:
Ember 2024-08-31 02:50:04 +08:00
parent 139a096c41
commit b45adebeb8
21 changed files with 28 additions and 46 deletions

View File

@ -100,7 +100,7 @@ if (!loggedIn || !email) {
const userInfoBlob = new Blob([JSON.stringify(verificationData)], { type: 'application/json' });
try {
await client.put(`user/${email}/qv.json`, userInfoBlob);
setVerifiedCookie(email);
// setVerifiedCookie(email);
alert("您已完成验证!");
window.location.href = "/submission";
} catch (err) {
@ -117,10 +117,10 @@ if (!loggedIn || !email) {
});
}
function setVerifiedCookie(email) {
const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
const expires = new Date(Date.now() + 20 * 60 * 1000).toUTCString(); // 20分钟
document.cookie = `loggedIn=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
document.cookie = `userEmail=${email}; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
document.cookie = `verified=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
}
// function setVerifiedCookie(email) {
// const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
// const expires = new Date(Date.now() + 20 * 60 * 1000).toUTCString(); // 20分钟
// document.cookie = `loggedIn=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
// document.cookie = `userEmail=${email}; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
// document.cookie = `verified=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
// }

2
js/qv.min.js vendored
View File

@ -1 +1 @@
let client;async function f1(){try{var e=await(await fetch("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json")).json(),t=e.masterKey,o=CryptoJS.SHA256(t),i={region:d2(e.encryptedRegion,o),accessKeyId:d2(e.encryptedKeyId,o),accessKeySecret:d2(e.encryptedKeySecret,o),bucket:d2(e.encryptedBucket,o)};client=new OSS(i)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");var e=CryptoJS.enc.Base64.parse(e),o=CryptoJS.lib.WordArray.create(e.words.slice(0,4)),e=CryptoJS.lib.WordArray.create(e.words.slice(4));return CryptoJS.AES.decrypt({ciphertext:e},t,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}function getCookie(e){var o=e+"=",i=document.cookie.split(";");for(let t=0;t<i.length;t++){let e=i[t];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(o))return e.substring(o.length,e.length)}return null}document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{client||console.error("Failed to initialize OSS client due to decryption error.")}).catch(e=>{console.log("Error initializing OSS Client:",e)})});let loggedIn=getCookie("loggedIn"),email=getCookie("userEmail");if(loggedIn&&email){let e=async()=>{try{var e=await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${email}/qv.json`);e.ok&&!0===await e.json()&&(alert("您已经完成验证,无需再次验证!"),window.location.href="/submission")}catch(e){console.log("没有找到验证文件,继续验证流程。")}};e(),document.getElementById("verifybtn").addEventListener("click",async()=>{try{if((await(await fetch("https://ipquery.xn--xhq44jb2fzpc.com/api/check-ip")).json()).data.isInNeU){var e=new Blob([JSON.stringify(!0)],{type:"application/json"});try{await client.put(`user/${email}/qv.json`,e),setVerifiedCookie(email),alert("您已完成验证!"),window.location.href="/submission"}catch(e){console.error("OSS写入失败:",e),alert("验证失败,请稍后重试。")}}else alert("您未连接NEU校园网请连接后重试")}catch(e){console.error("IP验证失败:",e),alert("验证失败,请稍后重试。")}})}else alert("您未登录,请先登录后操作!"),window.location.href="/submission";function setVerifiedCookie(e){var t=window.location.hostname.includes("localhost")?"localhost":"."+window.location.hostname.split(".").slice(-2).join("."),o=new Date(Date.now()+12e5).toUTCString();document.cookie=`loggedIn=true; domain=${t}; path=/; expires=${o}; SameSite=Lax`,document.cookie=`userEmail=${e}; domain=${t}; path=/; expires=${o}; SameSite=Lax`,document.cookie=`verified=true; domain=${t}; path=/; expires=${o}; SameSite=Lax`}
let client;async function f1(){try{var e=await(await fetch("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json")).json(),t=e.masterKey,o=CryptoJS.SHA256(t),n={region:d2(e.encryptedRegion,o),accessKeyId:d2(e.encryptedKeyId,o),accessKeySecret:d2(e.encryptedKeySecret,o),bucket:d2(e.encryptedBucket,o)};client=new OSS(n)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");var e=CryptoJS.enc.Base64.parse(e),o=CryptoJS.lib.WordArray.create(e.words.slice(0,4)),e=CryptoJS.lib.WordArray.create(e.words.slice(4));return CryptoJS.AES.decrypt({ciphertext:e},t,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}function getCookie(e){var o=e+"=",n=document.cookie.split(";");for(let t=0;t<n.length;t++){let e=n[t];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(o))return e.substring(o.length,e.length)}return null}document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{client||console.error("Failed to initialize OSS client due to decryption error.")}).catch(e=>{console.log("Error initializing OSS Client:",e)})});let loggedIn=getCookie("loggedIn"),email=getCookie("userEmail");if(loggedIn&&email){let e=async()=>{try{var e=await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${email}/qv.json`);e.ok&&!0===await e.json()&&(alert("您已经完成验证,无需再次验证!"),window.location.href="/submission")}catch(e){console.log("没有找到验证文件,继续验证流程。")}};e(),document.getElementById("verifybtn").addEventListener("click",async()=>{try{if((await(await fetch("https://ipquery.xn--xhq44jb2fzpc.com/api/check-ip")).json()).data.isInNeU){var e=new Blob([JSON.stringify(!0)],{type:"application/json"});try{await client.put(`user/${email}/qv.json`,e),alert("您已完成验证!"),window.location.href="/submission"}catch(e){console.error("OSS写入失败:",e),alert("验证失败,请稍后重试。")}}else alert("您未连接NEU校园网请连接后重试")}catch(e){console.error("IP验证失败:",e),alert("验证失败,请稍后重试。")}})}else alert("您未登录,请先登录后操作!"),window.location.href="/submission";

View File

@ -26,32 +26,14 @@ document.addEventListener('DOMContentLoaded', function() {
});
// 设置登录状态的 Cookie
async function setLoginCookie(email) {
function setLoginCookie(email) {
const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
const expires = new Date(Date.now() + 20 * 60 * 1000).toUTCString(); // 20分钟
// 设置基本的登录状态和用户邮箱的Cookie
document.cookie = `loggedIn=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
document.cookie = `userEmail=${email}; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
// 检查是否有验证文件并且内容为true
const verificationFilePath = `https://download.xn--xhq44jb2fzpc.com/user/${email}/qv.json`;
try {
const response = await fetch(verificationFilePath);
if (response.ok) {
const data = await response.json();
if (data === true) {
// 设置verified为true的Cookie
document.cookie = `verified=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
}
}
} catch (error) {
console.error('Error checking verification status:', error);
}
}
function logout() {
const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;

File diff suppressed because one or more lines are too long

View File

@ -286,7 +286,7 @@
</style>
<script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-6.18.0.min.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/password/crypto-js.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/qv.min.js?v=1.0.1"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/qv.min.js?v=1.0.2"></script>
</div>

View File

@ -587,7 +587,7 @@
</script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.min.js"></script>

View File

@ -586,7 +586,7 @@ document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{if(client
</script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.min.js"></script>

View File

@ -586,7 +586,7 @@ document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{if(client
</script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.min.js"></script>

View File

@ -583,7 +583,7 @@
</script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.min.js"></script>

View File

@ -583,7 +583,7 @@
</script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.min.js"></script>

Some files were not shown because too many files have changed in this diff Show More