mirror of
https://github.com/r-ca/kidshift-be.git
synced 2024-10-25 16:14:02 +00:00
定数を使ってレスポンスするように
This commit is contained in:
parent
4aa4997a2d
commit
12ba1bf265
|
@ -1,18 +1,15 @@
|
|||
import { Request, Response, NextFunction } from "express";
|
||||
import { Role } from "@src/enums";
|
||||
import { jwtVerifyErrorResponse, notPermittedResponse } from "@src/models/commons/responses";
|
||||
|
||||
export default function verifyParent(req: Request, res: Response, next: NextFunction) {
|
||||
if (req.user) {
|
||||
if (req.user.claims.role === Role.PARENT) {
|
||||
next();
|
||||
} else {
|
||||
res.status(401).json({
|
||||
message: '権限がありません(保護者のみ利用可能なAPIです)'
|
||||
});
|
||||
res.status(notPermittedResponse().statusCode).json(notPermittedResponse().body);
|
||||
}
|
||||
} else {
|
||||
res.status(500).json({
|
||||
message: 'エラーが発生しました(JWT解析結果が不正/未設定です)'
|
||||
});
|
||||
res.status(jwtVerifyErrorResponse().statusCode).json(jwtVerifyErrorResponse().body);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user