Merge branch 'dev/methapon' into develop
This commit is contained in:
commit
81b4e25086
3 changed files with 6 additions and 4 deletions
|
|
@ -5,8 +5,10 @@ export function calculateAge(start: Date, end = new Date()) {
|
||||||
let month = end.getMonth() - start.getMonth();
|
let month = end.getMonth() - start.getMonth();
|
||||||
let day = end.getDate() - start.getDate();
|
let day = end.getDate() - start.getDate();
|
||||||
|
|
||||||
if (month < 0) year -= 1;
|
if (month < 0) {
|
||||||
if (month < 0) month += 12;
|
month += 12;
|
||||||
|
year -= 1;
|
||||||
|
}
|
||||||
if (day < 0) {
|
if (day < 0) {
|
||||||
month -= 1;
|
month -= 1;
|
||||||
day =
|
day =
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { RequestWithUser } from "./user";
|
||||||
|
|
||||||
export function authRole(
|
export function authRole(
|
||||||
role: string | string[],
|
role: string | string[],
|
||||||
errorMessage = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว",
|
errorMessage: string = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว",
|
||||||
) {
|
) {
|
||||||
return (req: RequestWithUser, _res: express.Response, next: express.NextFunction) => {
|
return (req: RequestWithUser, _res: express.Response, next: express.NextFunction) => {
|
||||||
if ((Array.isArray(role) && role.includes("*")) || role === "*") return next();
|
if ((Array.isArray(role) && role.includes("*")) || role === "*") return next();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"entryFile": "src/app.ts",
|
"entryFile": "src/app.ts",
|
||||||
"noImplicitAdditionalProperties": "throw-on-extras",
|
"noImplicitAdditionalProperties": "throw-on-extras",
|
||||||
"controllerPathGlobs": ["src/controllers/*Controller.ts"],
|
"controllerPathGlobs": ["src/controllers/**/*Controller.ts"],
|
||||||
"spec": {
|
"spec": {
|
||||||
"outputDirectory": "src",
|
"outputDirectory": "src",
|
||||||
"specVersion": 3,
|
"specVersion": 3,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue