From b43abb4b5ddc602e181fa6bd33dced8c5c2ca448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 27 Mar 2019 01:06:15 +0800 Subject: [PATCH] web api --- web/controllers/base.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/controllers/base.go b/web/controllers/base.go index db35e1e..631efbc 100755 --- a/web/controllers/base.go +++ b/web/controllers/base.go @@ -6,6 +6,7 @@ import ( "github.com/cnlh/nps/lib/file" "github.com/cnlh/nps/server" "github.com/cnlh/nps/vender/github.com/astaxie/beego" + "math" "strconv" "strings" "time" @@ -29,7 +30,7 @@ func (s *BaseController) Prepare() { timestamp := s.GetIntNoErr("timestamp") configKey := beego.AppConfig.String("auth_key") timeNowUnix := time.Now().Unix() - if !(((timeNowUnix - int64(timestamp)) <= 20) && ((timeNowUnix - int64(timestamp)) >= -20) && (crypt.Md5(configKey+strconv.Itoa(timestamp)) == md5Key)) { + if !((math.Abs(float64(timeNowUnix-int64(timestamp))) <= 20) && (crypt.Md5(configKey+strconv.Itoa(timestamp)) == md5Key)) { if s.GetSession("auth") != true { s.Redirect("/login/index", 302) }