fix(老师权限): 老师在自己比赛里点题目「可见」没反应、看不到学生的智能分析入口等一批权限错位
- 比赛题的可见开关按题目作者判归属,从题库加进比赛的题作者是别人,老师点了 404 且无提示; 改成和编辑、删除一样按比赛创建者判(canEdit) - 学生主页「智能分析」和「查看指定用户」只给超管,后端本来就允许老师;改成老师可见 - 排名页班级详情的「AI 分析」学生也看得到,点了权限不足;只给老师显示 - 班级 PK 页解构 store 丢了响应性,资料晚到时老师看不到「AI 分析」 - 学生管理员能给任何人的流程图重新评分且不限流;别人的提交只有老师能重评,免限流也只给老师 - 超管没退登就过期的机房电脑上,下一个登录的老师继承演示模式、看不到后台和看板且关不掉; 演示模式只对超管生效 - 老师的出题权限能设成「无权限」,设了比赛题目页全是权限不足;后端兜成「仅自己」, 编辑框里老师不再给这个选项 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bde387e8bc
commit
30f34f0e36
10 files changed
+45
-15
No files matched your search
@@ -30,6 +30,7 @@ import { unknownDisplayIds } from "./submission-statistics"
|
||||
import {
|
||||
classCondition,
|
||||
isAdminRole,
|
||||
isTeacherOrAbove,
|
||||
matchedUsers,
|
||||
asRecord,
|
||||
parseDisplayIds,
|
||||
@@ -663,11 +664,15 @@ flowchartRoutes.post("/flowcharts/:id/retry", requireAuth, async (c) => {
|
||||
.limit(1)
|
||||
if (!row || !canView(user, row.flowchart, row.problem, await joinTimesFor(user, [row.flowchart])))
|
||||
return failure(c, 404, "flowchart-not-found", "Submission does not exist")
|
||||
// 看得见不等于能重评:canView 放进来的学生管理员、出题人只能看。重评会清掉原来的
|
||||
// 评分再抽一次,别人的提交只有老师能动
|
||||
if (row.flowchart.userId !== user.id && !isTeacherOrAbove(user))
|
||||
return failure(c, 403, "permission-denied", "权限不足")
|
||||
if (![2, 3].includes(row.flowchart.status))
|
||||
return failure(c, 409, "retry-not-allowed", "Submission is not in a state that allows retry")
|
||||
// canView 允许本人重试自己的提交,不限流的话学生可以反复点着刷 AI 调用。
|
||||
// 教师放行:重新判题是他们的日常操作,成批点几十行是正常用法
|
||||
if (!isAdminRole(user)) {
|
||||
if (!isTeacherOrAbove(user)) {
|
||||
const throttle = await consumeToken("user", flowchartThrottleKey(user.id))
|
||||
if (!throttle.allowed) {
|
||||
return failure(
|
||||
|
||||
Reference in new issue
Block a user