Browse Source

Merge branch 'feature/token_time_0913' into debug

hsun 1 year ago
parent
commit
f8a306a20a
3 changed files with 11 additions and 9 deletions
  1. 2 2
      controllers/base_auth.go
  2. 2 2
      controllers/user_login.go
  3. 7 5
      utils/constants.go

+ 2 - 2
controllers/base_auth.go

@@ -185,10 +185,10 @@ func (this *BaseAuthController) Prepare() {
 					this.StopRun()
 					return
 				}
-				utils.Rc.Put(loginKey, "1", 30*time.Minute)
+				utils.Rc.Put(loginKey, "1", utils.LoginCacheTime*time.Minute)
 				// 不信任名单也同步更新
 				noTrustLoginKey := fmt.Sprint(utils.CACHE_ACCESS_TOKEN_LOGIN_NO_TRUST, admin.AdminId)
-				utils.Rc.Put(noTrustLoginKey, session.Id, 30*time.Minute)
+				utils.Rc.Put(noTrustLoginKey, session.Id, utils.LoginCacheTime*time.Minute)
 			}
 
 			admin.RoleTypeCode = GetSysUserRoleTypeCode(admin.RoleTypeCode)

+ 2 - 2
controllers/user_login.go

@@ -532,13 +532,13 @@ func (this *UserLoginController) Login() {
 		noTrustLoginId, _ := utils.Rc.RedisString(noTrustLoginKey)
 		if noTrustLoginId != `` { // 如果存在不可信设备,那么将其下架
 			oldNoTrustLoginKey := fmt.Sprint(utils.CACHE_ACCESS_TOKEN_LOGIN, noTrustLoginId)
-			_ = utils.Rc.Put(oldNoTrustLoginKey, "0", 30*time.Minute)
+			_ = utils.Rc.Put(oldNoTrustLoginKey, "0", utils.LoginCacheTime*time.Minute)
 		}
 
 		// 如果当前是不可信设备,那么将其加入到不可信名单
 		loginKey := fmt.Sprint(utils.CACHE_ACCESS_TOKEN_LOGIN, sysSession.Id)
 		_ = utils.Rc.Put(loginKey, "1", 30*time.Minute)
-		_ = utils.Rc.Put(noTrustLoginKey, sysSession.Id, 30*time.Minute)
+		_ = utils.Rc.Put(noTrustLoginKey, sysSession.Id, utils.LoginCacheTime*time.Minute)
 	}
 
 	// 新增登录记录

+ 7 - 5
utils/constants.go

@@ -403,9 +403,9 @@ const (
 	ZHUAN_JIA_NAME                          string = "专家"
 	ZHUAN_JIA_ID                            int    = 29
 	CHART_PERMISSION_NAME_70W                      = "70w大套餐" // 权益70w大套餐名称
-	CHART_PERMISSION_ID_70W                        = 2001        // 权益70w大套餐表示的权限ID(自定义)
+	CHART_PERMISSION_ID_70W                        = 2001     // 权益70w大套餐表示的权限ID(自定义)
 	CHART_PERMISSION_NAME_45W                      = "45w大套餐" // 权益45w大套餐名称
-	CHART_PERMISSION_ID_45W                        = 2002        // 权益45w大套餐表示的权限ID(自定义)
+	CHART_PERMISSION_ID_45W                        = 2002     // 权益45w大套餐表示的权限ID(自定义)
 )
 
 const (
@@ -536,7 +536,9 @@ const CrmEtaAuthorization = "NIi1RbEmH0C2rksXtPGDPBBgRgTZY87Q"
 
 // 查研观向 研选专栏 作者头像和背景
 const (
-	CYGX_YANXUAN_SPECIAL_HEAD_IMG_URL = "https://hzstatic.hzinsights.com/cygx/yanxuan_special/head_img/Mask%20group-"
-	CYGX_YANXUAN_SPECIAL_BG_IMG_URL = "https://hzstatic.hzinsights.com/cygx/yanxuan_special/bg_img/"
+	CYGX_YANXUAN_SPECIAL_HEAD_IMG_URL  = "https://hzstatic.hzinsights.com/cygx/yanxuan_special/head_img/Mask%20group-"
+	CYGX_YANXUAN_SPECIAL_BG_IMG_URL    = "https://hzstatic.hzinsights.com/cygx/yanxuan_special/bg_img/"
 	CYGX_YANXUAN_SPECIAL_BG_IMG_URL_PC = "https://hzstatic.hzinsights.com/cygx/yanxuan_special/bg_img/pc/"
-)
+)
+
+const LoginCacheTime = 60 // 登录缓存时长, 分钟