修改了bug
This commit is contained in:
+21
-6
@@ -26,6 +26,19 @@ async function requireAuth(ctx, next) {
|
||||
await next();
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员校验中间件:仅管理端小程序绑定的账号可访问管理端接口
|
||||
* 与 WS 管理端 agent 的校验口径保持一致(app 中是否存在 wxapp-escort-admin)
|
||||
*/
|
||||
async function requireAdmin(ctx, next) {
|
||||
const user = ctx.state.user;
|
||||
if (!user || !user.app || !("wxapp-escort-admin" in user.app)) {
|
||||
ResponseUtil.forbidden(ctx, "无管理员权限");
|
||||
return;
|
||||
}
|
||||
await next();
|
||||
}
|
||||
|
||||
function printRoutes(stack) {
|
||||
for (const layer of stack) {
|
||||
if (layer.path) {
|
||||
@@ -46,7 +59,8 @@ function registerRoutes(app) {
|
||||
// 敏感数据路由需要登录后访问
|
||||
router.get("/escort-record/my", requireAuth, handlerEscortRecord.getMyRecords.bind(handlerEscortRecord));
|
||||
router.get("/escort-record/attendant", requireAuth, handlerEscortRecord.getAttendantRecords.bind(handlerEscortRecord));
|
||||
router.get("/escort-record", requireAuth, handlerEscortRecord.getRecords.bind(handlerEscortRecord));
|
||||
// 全量查询属管理端能力,必须管理员
|
||||
router.get("/escort-record", requireAuth, requireAdmin, handlerEscortRecord.getRecords.bind(handlerEscortRecord));
|
||||
router.get("/escort-record/:id", requireAuth, handlerEscortRecord.getRecordById.bind(handlerEscortRecord));
|
||||
router.post("/escort-record", requireAuth, handlerEscortRecord.createRecord.bind(handlerEscortRecord));
|
||||
router.put("/escort-record/:id", requireAuth, handlerEscortRecord.updateRecord.bind(handlerEscortRecord));
|
||||
@@ -60,11 +74,12 @@ function registerRoutes(app) {
|
||||
router.put("/health-profile/mine/:id", requireAuth, handlerHealthProfile.updateMyProfile.bind(handlerHealthProfile));
|
||||
router.delete("/health-profile/mine/:id", requireAuth, handlerHealthProfile.deleteMyProfile.bind(handlerHealthProfile));
|
||||
|
||||
router.get("/health-profile", requireAuth, handlerHealthProfile.getProfiles.bind(handlerHealthProfile));
|
||||
router.get("/health-profile/:id", requireAuth, handlerHealthProfile.getProfileById.bind(handlerHealthProfile));
|
||||
router.post("/health-profile", requireAuth, handlerHealthProfile.createProfile.bind(handlerHealthProfile));
|
||||
router.put("/health-profile/:id", requireAuth, handlerHealthProfile.updateProfile.bind(handlerHealthProfile));
|
||||
router.delete("/health-profile/:id", requireAuth, handlerHealthProfile.deleteProfile.bind(handlerHealthProfile));
|
||||
// 以下为管理端档案接口(C 端一律走 /mine),必须管理员
|
||||
router.get("/health-profile", requireAuth, requireAdmin, handlerHealthProfile.getProfiles.bind(handlerHealthProfile));
|
||||
router.get("/health-profile/:id", requireAuth, requireAdmin, handlerHealthProfile.getProfileById.bind(handlerHealthProfile));
|
||||
router.post("/health-profile", requireAuth, requireAdmin, handlerHealthProfile.createProfile.bind(handlerHealthProfile));
|
||||
router.put("/health-profile/:id", requireAuth, requireAdmin, handlerHealthProfile.updateProfile.bind(handlerHealthProfile));
|
||||
router.delete("/health-profile/:id", requireAuth, requireAdmin, handlerHealthProfile.deleteProfile.bind(handlerHealthProfile));
|
||||
|
||||
router.get("/service", handlerResource.getServices.bind(handlerResource));
|
||||
router.get("/agreement", handlerResource.getAgreement.bind(handlerResource));
|
||||
|
||||
Reference in New Issue
Block a user