"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const normalize_1=require("../utils/normalize"),responseCode_1=require("../utils/responseCode"),notAuthPath=["/evaservice/admin/login","/evaservice/upload","/station/upload"];async function auth(h,a){const{path:b,method:c}=h.request;if("POST"===c.toUpperCase()&&!notAuthPath.includes(b)){let i=!1;const c=h.cookies.get("token",{encrypt:!0}).split(".");if(Array.isArray(c)&&3===c.length){const[a,b,d]=c,e=parseInt(b,10);a===h.ip.replace(/\./g,"")&&3e5>=Date.now()-e&&d&&(i=!0)}i?await a():h.response.body=normalize_1.NMLResponse(responseCode_1.ResponseCode.AUTH_FAIL,null,"\u8EAB\u4EFD\u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55")}else await a()}exports.default=()=>auth;