From af88e9c52e8d08d8a2e5c0001b08dbc478429bec Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 8 Aug 2019 17:14:45 +0800 Subject: [PATCH] =?UTF-8?q?-=20ren=20AuthInfo.ExpiresIn=20to=20ExpiresAt?= =?UTF-8?q?=20-=20=E5=B0=86auth2=E4=B8=AD=E4=B8=8D=E6=98=AF=E5=B0=8F?= =?UTF-8?q?=E9=A9=BC=E5=B3=B0=E7=9A=84=E5=85=A8=E9=83=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/auth2/auth2.go | 4 ++-- business/auth2/auth_info.go | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index 06d5304ad..250a05fb7 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -122,7 +122,7 @@ func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) { authInfo = &AuthInfo{ AuthBindInfo: authBindInfo, LoginTime: time.Now(), - ExpiresIn: time.Now().Add(DefTokenDuration).Unix(), + ExpiresAt: time.Now().Add(DefTokenDuration).Unix(), Token: token, TokenType: tokenType, } @@ -131,7 +131,7 @@ func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) { globals.SugarLogger.Debugf("createAuthInfo id:%s, id2:%s, mobile:%s, authInfo:%s", authInfo.GetID(), authInfo.GetID2(), authInfo.GetMobile(), utils.Format4Output(authInfo, true)) } else { expireDuration = TmpTokenDuration - authInfo.ExpiresIn = time.Now().Add(expireDuration).Unix() + authInfo.ExpiresAt = time.Now().Add(expireDuration).Unix() globals.SugarLogger.Debugf("createAuthInfo authInfo:%s", utils.Format4Output(authInfo, true)) } SetUserInfo(token, authInfo, expireDuration) diff --git a/business/auth2/auth_info.go b/business/auth2/auth_info.go index 7b5484fcc..f646e231f 100644 --- a/business/auth2/auth_info.go +++ b/business/auth2/auth_info.go @@ -13,11 +13,11 @@ const ( ) type UserBasic struct { - UserID string - UserID2 string - Mobile string - Email string - Name string + UserID string `json:"userID"` + UserID2 string `json:"userID2"` + Mobile string `json:"mobile"` + Email string `json:"email"` + Name string `json:"name"` } func (u *UserBasic) GetID() string { @@ -55,18 +55,18 @@ func (u *UserBasic) IsUserEmpty() bool { type AuthBindEx struct { model.AuthBind - UserData interface{} // 认证成功后得到的原始用户信息 - UserHint *UserBasic // 认证成功后得到的一些可能的基本用户信息(主要有用信息是手机号,email与用户名) + UserData interface{} `json:"userData"` // 认证成功后得到的原始用户信息 + UserHint *UserBasic `json:"userHint"` // 认证成功后得到的一些可能的基本用户信息(主要有用信息是手机号,email与用户名) } type AuthInfo struct { - UserBasic // 登录成功后保存的用户信息 - AuthBindInfo *AuthBindEx + UserBasic // 登录成功后保存的用户信息 + AuthBindInfo *AuthBindEx `json:"authBindInfo"` - LoginTime time.Time - ExpiresIn int64 - Token string - TokenType int // TOKEN类型, + LoginTime time.Time `json:"loginTime"` + ExpiresAt int64 `json:"expiresAt"` + Token string `json:"token"` + TokenType int `json:"tokenType"` // TOKEN类型, } func (a *AuthInfo) GetAuthID() string {