feat: 用户权限增强 - 非管理员仅能看到自己
- GET /api/users: 非管理员仅返回自己的用户信息
- GET /api/users/{id}: 非管理员只能查询自己,否则返回403
- 管理页面: 非管理员隐藏导航栏管理链接
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3021,7 +3021,7 @@ def get_admin_page_html() -> str:
|
||||
<a href="/reading">阅读</a>
|
||||
<a href="/report">报告</a>
|
||||
<a href="/settings">设置</a>
|
||||
<a href="/admin" class="active">管理</a>
|
||||
<a href="/admin" id="admin-nav-link" class="active">管理</a>
|
||||
<div class="spacer"></div>
|
||||
<span class="user-info" id="userInfo"></span>
|
||||
<button class="logout-btn" onclick="logout()">退出</button>
|
||||
@@ -3164,6 +3164,9 @@ def get_admin_page_html() -> str:
|
||||
document.getElementById('userInfo').textContent = currentUser.name;
|
||||
|
||||
if (!currentUser.is_admin) {
|
||||
// 隐藏导航栏中的管理链接
|
||||
const adminNavLink = document.getElementById('admin-nav-link');
|
||||
if (adminNavLink) adminNavLink.style.display = 'none';
|
||||
document.getElementById('unauthorizedView').style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user