pull/1091/merge
zgbsm 2022-08-06 06:31:52 +00:00 committed by GitHub
commit 09d95b2447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -33,6 +33,9 @@ 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 configKey == "" {
configKey = crypt.GetRandomString(128)
}
if !(md5Key != "" && (math.Abs(float64(timeNowUnix-int64(timestamp))) <= 20) && (crypt.Md5(configKey+strconv.Itoa(timestamp)) == md5Key)) { if !(md5Key != "" && (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(beego.AppConfig.String("web_base_url")+"/login/index", 302) s.Redirect(beego.AppConfig.String("web_base_url")+"/login/index", 302)