mirror of https://github.com/qwqdanchun/nps.git
web api
This commit is contained in:
parent
d42710497c
commit
b43abb4b5d
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/cnlh/nps/lib/file"
|
"github.com/cnlh/nps/lib/file"
|
||||||
"github.com/cnlh/nps/server"
|
"github.com/cnlh/nps/server"
|
||||||
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
|
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
|
||||||
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -29,7 +30,7 @@ func (s *BaseController) Prepare() {
|
||||||
timestamp := s.GetIntNoErr("timestamp")
|
timestamp := s.GetIntNoErr("timestamp")
|
||||||
configKey := beego.AppConfig.String("auth_key")
|
configKey := beego.AppConfig.String("auth_key")
|
||||||
timeNowUnix := time.Now().Unix()
|
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 {
|
if s.GetSession("auth") != true {
|
||||||
s.Redirect("/login/index", 302)
|
s.Redirect("/login/index", 302)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue