feat: 增加员工端工作台后端能力

This commit is contained in:
湛兮
2026-06-02 12:23:00 +08:00
parent 667dc411fc
commit 98cea63203
33 changed files with 3021 additions and 18 deletions
+11 -1
View File
@@ -2,7 +2,7 @@ import type { FastifyInstance } from "fastify";
import { env } from "../../config/env";
import { ok } from "../../shared/response";
import { authGuard } from "./auth.guard";
import { loginBodySchema } from "./auth.schema";
import { loginBodySchema, updateOwnPasswordBodySchema } from "./auth.schema";
import { authService } from "./auth.service";
export async function authRoutes(app: FastifyInstance): Promise<void> {
@@ -50,4 +50,14 @@ export async function authRoutes(app: FastifyInstance): Promise<void> {
return ok(user);
});
app.patch("/auth/me/password", { preHandler: authGuard }, async (request) => {
const body = updateOwnPasswordBodySchema.parse(request.body);
const user = await authService.updateOwnPassword(request.user, body, {
ip: request.ip,
userAgent: request.headers["user-agent"] ?? null,
});
return ok(user);
});
}