refactor: 更新认证方式为密码验证
简化认证流程,移除用户名,只需要输入访问密码: ## 后端更改 - 移除 JWT_SECRET、ADMIN_USERNAME、ADMIN_PASSWORD 配置 - 添加 ACCESS_PASSWORD 配置 - 更新认证接口:POST /api/auth/verify-password - 简化 JWT payload,只包含认证状态和时间戳 - 移除用户管理相关代码 - 更新认证中间件 ## 前端更改 - 登录页面只显示密码输入框 - 移除用户名输入和相关状态 - 更新 Pinia store 为 verifyPassword 方法 - 移除 User 类型定义 - 更新布局和设置页面 ## 文档更改 - 更新 README.md 说明新的认证方式 - 更新 DEVELOPMENT_GUIDE.md 环境变量配置 - 更新 API.md 认证接口文档 - 更新 .env.example 配置模板 ## 安全改进 - 使用 ACCESS_PASSWORD 作为 JWT 签名密钥 - 自动清理过期会话(7天) - 简化配置,更易于部署 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed626e74dc
commit
903dc1e61f
15 files changed
+124
-171
No files matched your search
@@ -33,7 +33,7 @@
|
||||
<el-dropdown @command="handleCommand">
|
||||
<span class="user-dropdown">
|
||||
<el-icon><User /></el-icon>
|
||||
{{ username }}
|
||||
管理员
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
@@ -61,7 +61,6 @@ const router = useRouter();
|
||||
const route = useRoute();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const username = computed(() => authStore.user?.username || '');
|
||||
const currentRoute = computed(() => route.path);
|
||||
const currentTitle = computed(() => route.meta.title || 'CC Cloud');
|
||||
|
||||
|
||||
@@ -9,22 +9,14 @@
|
||||
</template>
|
||||
|
||||
<el-form :model="loginForm" :rules="rules" ref="formRef" @submit.prevent="handleLogin">
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
placeholder="用户名"
|
||||
prefix-icon="User"
|
||||
size="large"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
placeholder="密码"
|
||||
placeholder="请输入访问密码"
|
||||
prefix-icon="Lock"
|
||||
size="large"
|
||||
show-password
|
||||
@keyup.enter="handleLogin"
|
||||
/>
|
||||
</el-form-item>
|
||||
@@ -53,13 +45,11 @@ const formRef = ref<FormInstance>();
|
||||
const loading = ref(false);
|
||||
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
});
|
||||
|
||||
const rules: FormRules = {
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '请输入访问密码', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
const handleLogin = async () => {
|
||||
@@ -70,7 +60,7 @@ const handleLogin = async () => {
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
await authStore.login(loginForm);
|
||||
await authStore.verifyPassword(loginForm.password);
|
||||
ElMessage.success('登录成功');
|
||||
router.push('/');
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<h1>设置</h1>
|
||||
<el-card>
|
||||
<el-form label-width="120px">
|
||||
<el-form-item label="用户名">
|
||||
<el-input :value="username" disabled />
|
||||
<el-form-item label="用户角色">
|
||||
<el-input value="管理员" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="API 端点">
|
||||
<el-input value="/api" disabled />
|
||||
@@ -18,11 +18,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const username = computed(() => authStore.user?.username || '');
|
||||
// 设置页面
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in new issue
Block a user