feat: 增加员工端工作台后端能力
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user