删除了邀请码部分
Change-Id: I6bb6a1b3ec092bebdc9c33364b9b385c6519f989
Signed-off-by: Your Name <your.email@example.com>
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
index 8bb0c85..823ecdf 100644
--- a/src/main/resources/schema.sql
+++ b/src/main/resources/schema.sql
@@ -13,15 +13,7 @@
INDEX `idx_user_id` (`user_id`) -- 可选:主键通常自带索引
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-CREATE TABLE invite_code (
- code VARCHAR(20) PRIMARY KEY,
- max_uses INT NOT NULL,
- remaining_uses INT NOT NULL,
- expiry_time DATETIME NOT NULL,
- created_by INT NOT NULL,
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- FOREIGN KEY (created_by) REFERENCES user(user_id)
-);
+
CREATE TABLE user_follow (
follower_id INT NOT NULL,
@@ -38,8 +30,3 @@
'admin', 'admin@example.com', 'admin123', NOW(), 87654321, 'admin'
);
-INSERT INTO invite_code (
- code, max_uses, remaining_uses, expiry_time, created_by
-) VALUES
- ('WELCOME2025', 5, 5, '2026-01-01 00:00:00', 1),
- ('INVITEONLY', 3, 3, '2025-12-31 23:59:59', 1);
\ No newline at end of file
diff --git a/src/main/resources/static/home.html b/src/main/resources/static/home.html
index 635856a..5cac114 100644
--- a/src/main/resources/static/home.html
+++ b/src/main/resources/static/home.html
@@ -1,24 +1,30 @@
-<!-- src/main/resources/static/home.html -->
<!DOCTYPE html>
<html lang="zh-CN">
-<head><meta charset="UTF-8"><title>首页</title></head>
+<head>
+ <meta charset="UTF-8">
+ <title>首页</title>
+</head>
<body>
<h1>欢迎访问受保护页面</h1>
<div id="userInfo"></div>
<script>
- (async ()=>{
- const token = localStorage.getItem('token');
- if (!token) return window.location.href='login.html';
+ (async () => {
+ const token = localStorage.getItem('token'); // 从 localStorage 获取 token
+ if (!token) return window.location.href = 'login.html'; // 如果 token 不存在,重定向到登录页面
+
const res = await fetch('/api/me', {
- headers: { 'token': token }
+ headers: { 'token': token } // 使用 token 请求用户信息
});
- const json = await res.json();
- if (json.code!==0) {
- return window.location.href='login.html';
+
+ const json = await res.json(); // 解析响应数据
+ if (json.code !== 0) {
+ return window.location.href = 'login.html'; // 如果获取用户信息失败,重定向到登录页面
}
+
+ // 输出当前用户和 token
document.getElementById('userInfo')
- .innerText = '当前用户:' + json.data.username;
+ .innerText = '当前用户:' + json.data.username + ',Token:' + json.data; // 显示用户名和 token
})();
</script>
</body>
-</html>
+</html>
\ No newline at end of file
diff --git a/src/main/resources/static/register.html b/src/main/resources/static/register.html
index 1e43e90..549c790 100644
--- a/src/main/resources/static/register.html
+++ b/src/main/resources/static/register.html
@@ -19,8 +19,6 @@
<input type="password" name="password" required>
<label>身份证号(8 位数字):</label>
<input type="number" name="identificationNumber" required>
- <label>邀请码:</label>
- <input type="text" name="inviteCode" required>
<button type="submit">注册</button>
</form>
<script>
@@ -28,7 +26,6 @@
.addEventListener('click', async () => {
const form = new URLSearchParams();
form.set('email', document.querySelector('[name=email]').value);
- form.set('inviteCode', document.querySelector('[name=inviteCode]').value);
const res = await fetch('/sendVerification', {
method: 'POST',
body: form