修复验证系统bug
This commit is contained in:
parent
3f1f76f978
commit
139a096c41
9
js/qv.js
9
js/qv.js
@ -100,6 +100,7 @@ if (!loggedIn || !email) {
|
|||||||
const userInfoBlob = new Blob([JSON.stringify(verificationData)], { type: 'application/json' });
|
const userInfoBlob = new Blob([JSON.stringify(verificationData)], { type: 'application/json' });
|
||||||
try {
|
try {
|
||||||
await client.put(`user/${email}/qv.json`, userInfoBlob);
|
await client.put(`user/${email}/qv.json`, userInfoBlob);
|
||||||
|
setVerifiedCookie(email);
|
||||||
alert("您已完成验证!");
|
alert("您已完成验证!");
|
||||||
window.location.href = "/submission";
|
window.location.href = "/submission";
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -115,3 +116,11 @@ 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`;
|
||||||
|
}
|
2
js/qv.min.js
vendored
2
js/qv.min.js
vendored
@ -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),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";
|
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`}
|
@ -26,12 +26,30 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 设置登录状态的 Cookie
|
// 设置登录状态的 Cookie
|
||||||
function setLoginCookie(email) {
|
async function setLoginCookie(email) {
|
||||||
const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
|
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分钟
|
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 = `loggedIn=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
|
||||||
document.cookie = `userEmail=${email}; 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() {
|
function logout() {
|
||||||
@ -160,7 +178,7 @@ async function checkqv(curemail) {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data === true) {
|
if (data === true) {
|
||||||
// 用户已经完成NEU校园网认证
|
// 用户已经完成NEU校园网认证
|
||||||
console.log("NEU校园网认证已完成");
|
// console.log("NEU校园网认证已完成");
|
||||||
} else {
|
} else {
|
||||||
// 文件存在但内容不是true
|
// 文件存在但内容不是true
|
||||||
showCustomModal();
|
showCustomModal();
|
||||||
|
2
js/submission.min.js
vendored
2
js/submission.min.js
vendored
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@
|
|||||||
<meta name="robots" content="index, follow">
|
<meta name="robots" content="index, follow">
|
||||||
<title>NEU小站</title>
|
<title>NEU小站</title>
|
||||||
<meta name="keywords" content="">
|
<meta name="keywords" content="">
|
||||||
<meta name="description" content="
此资源需要登录后才能查看!
正在跳转到登录页面,请稍后……
">
|
<meta name="description" content="
此资源需要经过验证的账户才能查看!
正在跳转到登录页面,请稍后……
">
|
||||||
<meta name="author" content="
|
<meta name="author" content="
|
||||||
|
|
||||||
|
|
||||||
@ -223,7 +223,7 @@
|
|||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="title">此资源需要登录后才能查看!</div>
|
<div class="title">此资源需要经过验证的账户才能查看!</div>
|
||||||
<div class="con">正在跳转到登录页面,请稍后……</div>
|
<div class="con">正在跳转到登录页面,请稍后……</div>
|
||||||
</div>
|
</div>
|
||||||
<style>
|
<style>
|
||||||
|
@ -286,7 +286,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-6.18.0.min.js"></script>
|
<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/password/crypto-js.js"></script>
|
||||||
<script src="https://download.xn--xhq44jb2fzpc.com/upload/qv.min.js"></script>
|
<script src="https://download.xn--xhq44jb2fzpc.com/upload/qv.min.js?v=1.0.1"></script>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -587,27 +587,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const loggedIn = getCookie('loggedIn');
|
|
||||||
|
|
||||||
if (loggedIn !== 'true') {
|
|
||||||
|
|
||||||
window.location.href = "/loginrequired";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function getCookie(name) {
|
|
||||||
const nameEQ = name + "=";
|
|
||||||
const ca = document.cookie.split(';');
|
|
||||||
for(let i = 0; i < ca.length; i++) {
|
|
||||||
let c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') c = c.substring(1,c.length);
|
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -586,27 +586,7 @@ document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{if(client
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const loggedIn = getCookie('loggedIn');
|
|
||||||
|
|
||||||
if (loggedIn !== 'true') {
|
|
||||||
|
|
||||||
window.location.href = "/loginrequired";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function getCookie(name) {
|
|
||||||
const nameEQ = name + "=";
|
|
||||||
const ca = document.cookie.split(';');
|
|
||||||
for(let i = 0; i < ca.length; i++) {
|
|
||||||
let c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') c = c.substring(1,c.length);
|
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -586,27 +586,7 @@ document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{if(client
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const loggedIn = getCookie('loggedIn');
|
|
||||||
|
|
||||||
if (loggedIn !== 'true') {
|
|
||||||
|
|
||||||
window.location.href = "/loginrequired";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function getCookie(name) {
|
|
||||||
const nameEQ = name + "=";
|
|
||||||
const ca = document.cookie.split(';');
|
|
||||||
for(let i = 0; i < ca.length; i++) {
|
|
||||||
let c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') c = c.substring(1,c.length);
|
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -583,27 +583,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script src="https://download.xn--xhq44jb2fzpc.com/upload/loginrequired.js"></script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const loggedIn = getCookie('loggedIn');
|
|
||||||
|
|
||||||
if (loggedIn !== 'true') {
|
|
||||||
|
|
||||||
window.location.href = "/loginrequired";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function getCookie(name) {
|
|
||||||
const nameEQ = name + "=";
|
|
||||||
const ca = document.cookie.split(';');
|
|
||||||
for(let i = 0; i < ca.length; i++) {
|
|
||||||
let c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') c = c.substring(1,c.length);
|
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user