学生不再有登录能力:User.passwordHash 以空串占位,role=STUDENT 在密码校验之前 一律 403 并提示改用班级登录(否则「密码错 401 / 密码对但已停用 403」的差异会把 学生账号密码变成可离线验证的预言机)。成绩、未交名单、叫人、已读全部按名单记。 配套改动: - 删除 POST /students/:id/reset-password(调用返回 404,e2e 有负断言); - 新建学生不设密码,StudentsView 移除密码输入与「重置密码」入口, 列表标识仍自动生成为学号式(student01…); - class-account.ts / auth.service.ts 收紧班级会话语义; - 经管「修改密码」入口收敛到 Web 端:教师改本人密码走顶栏下拉, 班级密码由管理员在班级管理里维护,教师可用 POST /teachers/:id/reset-password 设初始密码。
25 lines
990 B
TypeScript
25 lines
990 B
TypeScript
import { z } from 'zod';
|
|
import { keywordSchema } from '../../lib/schemas.js';
|
|
|
|
export const listStudentsQuerySchema = z.object({
|
|
classId: z.string().min(1).optional(),
|
|
keyword: keywordSchema,
|
|
});
|
|
|
|
// 学生只有"名单"没有"账号":不设密码、不能登录(2026-10-01 起学生个人账号已全部清理,
|
|
// 学生端统一用班级码 + 班级密码),因此这里没有也不该有任何密码字段。
|
|
export const createStudentSchema = z.object({
|
|
username: z.string().trim().min(3, '用户名至少 3 位').max(32),
|
|
name: z.string().trim().min(1, '请输入姓名').max(32),
|
|
classId: z.string().min(1).nullish(),
|
|
});
|
|
|
|
export const updateStudentSchema = z.object({
|
|
username: z.string().trim().min(3).max(32).optional(),
|
|
name: z.string().trim().min(1).max(32).optional(),
|
|
classId: z.string().min(1).nullish(),
|
|
});
|
|
|
|
export type CreateStudentInput = z.infer<typeof createStudentSchema>;
|
|
export type UpdateStudentInput = z.infer<typeof updateStudentSchema>;
|