增加账户验证

This commit is contained in:
Ember 2024-08-31 01:20:39 +08:00
parent 7093ce6848
commit d10b5284c4
9 changed files with 663 additions and 7 deletions

117
js/qv.js Normal file

File diff suppressed because it is too large Load Diff

1
js/qv.min.js vendored Normal file
View File

@ -0,0 +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";

View File

@ -149,6 +149,33 @@ function initializeUserSession() {
checkInvitedStatus(curemail);
fetchSubmittedCount(curemail);
document.getElementById('userEmail').innerText = curemail;
checkqv(curemail);
}
async function checkqv(curemail) {
try {
const response = await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/qv.json`);
if (response.ok) {
const data = await response.json();
if (data === true) {
// 用户已经完成NEU校园网认证
console.log("NEU校园网认证已完成");
} else {
// 文件存在但内容不是true
alert("您未完成NEU校园网认证请前往认证");
window.location.href = "/qualification_verify";
}
} else {
// 文件不存在
alert("您未完成NEU校园网认证请前往认证");
window.location.href = "/qualification_verify";
}
} catch (error) {
console.error('检查NEU校园网认证状态时出错:', error);
alert("您未完成NEU校园网认证请前往认证");
window.location.href = "/qualification_verify";
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>NEU小站</title>
<link>https://xn--xhq44jb2fzpc.com/qualification_verify/</link>
<description>Recent content on NEU小站</description>
<generator>Hugo -- 0.127.0</generator>
<language>zh-cn</language>
<atom:link href="https://xn--xhq44jb2fzpc.com/qualification_verify/index.xml" rel="self" type="application/rss+xml" />
</channel>
</rss>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>https://xn--xhq44jb2fzpc.com/qualification_verify/</title>
<link rel="canonical" href="https://xn--xhq44jb2fzpc.com/qualification_verify/">
<meta name="robots" content="noindex">
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=https://xn--xhq44jb2fzpc.com/qualification_verify/">
</head>
</html>

View File

@ -119,6 +119,8 @@
<lastmod>2024-06-11T12:00:00+08:00</lastmod>
</url><url>
<loc>https://xn--xhq44jb2fzpc.com/loginrequired/</loc>
</url><url>
<loc>https://xn--xhq44jb2fzpc.com/qualification_verify/</loc>
</url><url>
<loc>https://xn--xhq44jb2fzpc.com/submissionsuccess/</loc>
</url><url>

View File

@ -7,7 +7,7 @@
<meta name="robots" content="index, follow">
<title>NEU小站</title>
<meta name="keywords" content="">
<meta name="description" content="用户中心 邮箱 密码 登录 未注册的用户将自动注册 我要投稿 个人信息 我的投稿 退出登录
<meta name="description" content="用户中心 邮箱 密码 登录 未注册的用户将自动注册为确保您是东北大学学生或教职工注册后需进行NEU校园网验证才能激活账户 我要投稿 个人信息 我的内容 退出登录
修改 Nickname V V 修改 email@example.com
请注意:由于浏览器缓存,修改头像或昵称后网站更新可能有延迟。
基本信息 投稿时间: 内容标题: 您想要投稿的板块为: 攻略指南 资源共享 说明:攻略指南板块主要用于提供学习和生活上的攻略信息或经验等,资源共享板块主要用于分享各类有价值的学习资源。
@ -262,7 +262,7 @@ async function fetchNoCache(url) {
</form>
<div id="message"></div>
<div class="center-text">
<br>未注册的用户将自动注册。
<br>未注册的用户将自动注册。为确保您是东北大学学生或教职工注册后需进行NEU校园网验证才能激活账户。
</div>
</div>
<script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-6.18.0.min.js"></script>
@ -328,7 +328,7 @@ async function fetchNoCache(url) {
<div id="navContainer" class="navContainer" style="display: none">
<button class="navButton" id="我要投稿" onclick="showSubmission()">我要投稿</button>
<button class="navButton" id="个人信息" onclick="showMyInfo()">个人信息</button>
<button class="navButton" id="我的投稿" onclick="showMySubmissions()">我的投稿</button>
<button class="navButton" id="我的内容" onclick="showMySubmissions()">我的内容</button>
</div>
<p><button id="logout" onclick="logout()" style="display: none">退出登录</button></p>
<style>
@ -611,6 +611,8 @@ async function fetchNoCache(url) {
</style>
<div id="mysubmission" style="display: none">
</div>
<div id="mycoin" style="display: none">
</div>
<div id="submission-area" style="display: none">
<h2 id="基本信息">基本信息<a hidden class="anchor" aria-hidden="true" href="#基本信息">#</a></h2>
<ul>
@ -890,7 +892,7 @@ async function fetchNoCache(url) {
</style>
<link rel="stylesheet" href="https://download.xn--xhq44jb2fzpc.com/upload/simplemde.min.css">
<script src="https://download.xn--xhq44jb2fzpc.com/upload/simplemde.min.js?v=1.0.4"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/submission.min.js?v=1.0.6"></script>
<script src="https://download.xn--xhq44jb2fzpc.com/upload/submission.min.js?v=1.0.7"></script>
<!-- <script src="/js/submission.js"></script> -->