feat: 权限修复、搜索改进、滑动切换、通知badge
All checks were successful
Deploy Production / test (push) Successful in 4s
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / deploy-preview (pull_request) Has been skipped
PR Preview / test (pull_request) Has been skipped
PR Preview / teardown-preview (pull_request) Successful in 13s
Deploy Production / deploy (push) Successful in 7s
Test / e2e-test (push) Successful in 52s
All checks were successful
Deploy Production / test (push) Successful in 4s
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / deploy-preview (pull_request) Has been skipped
PR Preview / test (pull_request) Has been skipped
PR Preview / teardown-preview (pull_request) Successful in 13s
Deploy Production / deploy (push) Successful in 7s
Test / e2e-test (push) Successful in 52s
权限: - viewer 不能编辑公共配方(前端+后端双重限制) - viewer 管理配方页只显示"我的配方" - 取消 token 链接登录,改为自注册+管理员分配角色 - 用户管理页去掉创建用户和复制链接,禁止设管理员 - 修复改权限 API 路径错误 搜索: - 模糊匹配+同义词扩展(37组),精确/相似分层 - 精确匹配不搜精油成分(避免"西班牙牛至"污染) - 所有搜索结果底部加"通知编辑添加"按钮 UI: - 顶部 tab 栏按用户角色显示,切换时居中滚动 - 左右滑动按 visibleTabs 顺序切换 tab - 用户名旁红色通知数 badge Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #18.
This commit is contained in:
@@ -781,15 +781,15 @@ def create_recipe(recipe: RecipeIn, user=Depends(get_current_user)):
|
||||
|
||||
|
||||
def _check_recipe_permission(conn, recipe_id, user):
|
||||
"""Check if user can modify this recipe."""
|
||||
"""Check if user can modify this recipe. Requires editor+ role."""
|
||||
row = conn.execute("SELECT owner_id, name FROM recipes WHERE id = ?", (recipe_id,)).fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, "Recipe not found")
|
||||
if user["role"] in ("admin", "senior_editor"):
|
||||
return row
|
||||
if row["owner_id"] == user.get("id"):
|
||||
if user["role"] in ("editor",) and row["owner_id"] == user.get("id"):
|
||||
return row
|
||||
raise HTTPException(403, "只能修改自己创建的配方")
|
||||
raise HTTPException(403, "权限不足")
|
||||
|
||||
|
||||
@app.put("/api/recipes/{recipe_id}")
|
||||
@@ -974,6 +974,9 @@ def delete_user(user_id: int, user=Depends(require_role("admin"))):
|
||||
def update_user(user_id: int, body: UserUpdate, user=Depends(require_role("admin"))):
|
||||
conn = get_db()
|
||||
if body.role is not None:
|
||||
if body.role == "admin":
|
||||
conn.close()
|
||||
raise HTTPException(403, "不能将用户设为管理员")
|
||||
conn.execute("UPDATE users SET role = ? WHERE id = ?", (body.role, user_id))
|
||||
if body.display_name is not None:
|
||||
conn.execute("UPDATE users SET display_name = ? WHERE id = ?", (body.display_name, user_id))
|
||||
|
||||
Reference in New Issue
Block a user