feat: add role-based access control and user article management
- Add AdminRequired middleware to all /admin routes for proper authorization - Restrict admin panel, comments, users, settings to admin role only - Create separate /my/articles routes for regular users to manage their own articles - Add MyArticlesPage handler for users to view/edit/delete their own content - Update navigation menus with role-based visibility - Admin dropdown shows only 'Admin Panel' link, other features in dashboard - Regular users see 'My Articles' link in profile dropdown - Add i18n translations for 'my_articles' and 'comment_manage' keys - Fix permission boundary issues where author role could access admin settings Security improvements: - Platform settings now require admin role - Comment moderation requires admin role - User management requires admin role - Regular users can only manage their own articles Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,7 @@ var translations = map[Lang]map[string]string{
|
||||
// Profile dropdown & page
|
||||
"profile": "Profile",
|
||||
"admin_panel": "Admin Panel",
|
||||
"my_articles": "My Articles",
|
||||
"profile_title": "Edit Profile",
|
||||
"profile_avatar": "Avatar",
|
||||
"profile_change_avatar": "Change Avatar",
|
||||
@@ -102,17 +103,28 @@ var translations = map[Lang]map[string]string{
|
||||
|
||||
// Article creation
|
||||
"article_create_title": "Create Article",
|
||||
"article_field_title": "Title",
|
||||
"article_title": "Title",
|
||||
"article_field_slug": "Slug",
|
||||
"article_slug": "Slug",
|
||||
"article_slug_hint": "Auto-generated from title if empty",
|
||||
"article_slug_help": "Auto-generated from title if empty",
|
||||
"article_field_summary": "Summary",
|
||||
"article_summary": "Summary",
|
||||
"article_field_content": "Content",
|
||||
"article_content": "Content",
|
||||
"article_field_cover": "Cover Image URL",
|
||||
"article_cover": "Cover Image URL",
|
||||
"article_cover_help": "Optional cover image URL",
|
||||
"article_field_status": "Status",
|
||||
"article_status": "Status",
|
||||
"article_draft": "Draft",
|
||||
"article_published": "Published",
|
||||
"article_field_is_top": "Pin to top",
|
||||
"article_is_top": "Pin to top",
|
||||
"article_save_draft": "Save Draft",
|
||||
"article_save": "Save",
|
||||
"article_cancel": "Cancel",
|
||||
"article_publish": "Publish",
|
||||
"article_created": "Article created successfully.",
|
||||
"article_error": "Failed to create article.",
|
||||
@@ -135,6 +147,7 @@ var translations = map[Lang]map[string]string{
|
||||
|
||||
// Article management
|
||||
"article_list_title": "Articles",
|
||||
"my_articles_title": "My Articles",
|
||||
"article_edit_title": "Edit Article",
|
||||
"article_manage": "Manage Articles",
|
||||
"article_edit": "Edit",
|
||||
@@ -241,6 +254,7 @@ var translations = map[Lang]map[string]string{
|
||||
|
||||
// Admin: comments
|
||||
"admin_comments": "Comments",
|
||||
"comment_manage": "Manage Comments",
|
||||
"admin_comments_title": "Comments",
|
||||
"comment_status_pending": "Pending",
|
||||
"comment_status_approved": "Approved",
|
||||
@@ -368,6 +382,7 @@ var translations = map[Lang]map[string]string{
|
||||
// 个人中心下拉菜单 & 页面
|
||||
"profile": "个人信息",
|
||||
"admin_panel": "后台管理",
|
||||
"my_articles": "我的文章",
|
||||
"profile_title": "编辑个人信息",
|
||||
"profile_avatar": "头像",
|
||||
"profile_change_avatar": "更换头像",
|
||||
@@ -398,17 +413,28 @@ var translations = map[Lang]map[string]string{
|
||||
|
||||
// 文章创建
|
||||
"article_create_title": "新建文章",
|
||||
"article_field_title": "标题",
|
||||
"article_title": "标题",
|
||||
"article_field_slug": "Slug",
|
||||
"article_slug": "Slug",
|
||||
"article_slug_hint": "留空则从标题自动生成",
|
||||
"article_slug_help": "留空则从标题自动生成",
|
||||
"article_field_summary": "摘要",
|
||||
"article_summary": "摘要",
|
||||
"article_field_content": "正文",
|
||||
"article_content": "正文",
|
||||
"article_field_cover": "封面图 URL",
|
||||
"article_cover": "封面图 URL",
|
||||
"article_cover_help": "可选的封面图片链接",
|
||||
"article_field_status": "状态",
|
||||
"article_status": "状态",
|
||||
"article_draft": "草稿",
|
||||
"article_published": "已发布",
|
||||
"article_field_is_top": "置顶",
|
||||
"article_is_top": "置顶",
|
||||
"article_save_draft": "保存草稿",
|
||||
"article_save": "保存",
|
||||
"article_cancel": "取消",
|
||||
"article_publish": "发布",
|
||||
"article_created": "文章创建成功。",
|
||||
"article_error": "创建文章失败。",
|
||||
@@ -431,6 +457,7 @@ var translations = map[Lang]map[string]string{
|
||||
|
||||
// 文章管理
|
||||
"article_list_title": "文章管理",
|
||||
"my_articles_title": "我的文章",
|
||||
"article_edit_title": "编辑文章",
|
||||
"article_manage": "文章管理",
|
||||
"article_edit": "编辑",
|
||||
@@ -537,6 +564,7 @@ var translations = map[Lang]map[string]string{
|
||||
|
||||
// 后台:评论
|
||||
"admin_comments": "评论管理",
|
||||
"comment_manage": "评论管理",
|
||||
"admin_comments_title": "评论管理",
|
||||
"comment_status_pending": "待审核",
|
||||
"comment_status_approved": "已通过",
|
||||
|
||||
Reference in New Issue
Block a user