Browse Source

手机用户token不过期

zoie 1 year ago
parent
commit
df737ce5df
1 changed files with 10 additions and 1 deletions
  1. 10 1
      pkg/jwtauth/jwtauth.go

+ 10 - 1
pkg/jwtauth/jwtauth.go

@@ -166,6 +166,7 @@ var (
 	// ErrFailedAuthentication indicates authentication failed, could be faulty username or password
 	//ErrFailedAuthentication = errors.New("incorrect Username or Password")
 	ErrFailedAuthentication = errors.New("用户名或密码不正确")
+	ErrFailedSmsVerifyCode = errors.New("短信验证码错误")
 
 	ErrAccountDeactivated = errors.New("账号已停用")
 
@@ -492,8 +493,16 @@ func (mw *GinJWTMiddleware) LoginHandler(c *gin.Context) {
 			claims[key] = value
 		}
 	}
-
 	expire := mw.TimeFunc().Add(mw.Timeout)
+
+	// 登录类型 手机登录
+	if t,ok := claims["mobile"];ok{
+		if t.(bool) {
+			expire = mw.TimeFunc().Add(time.Duration(876000) * time.Hour)
+
+		}
+	}
+
 	claims["exp"] = expire.Unix()
 	claims["orig_iat"] = mw.TimeFunc().Unix()
 	tokenString, err := mw.signedString(token)