Merge branch 'auth2' into mark

This commit is contained in:
gazebo
2019-08-09 09:33:27 +08:00
2 changed files with 15 additions and 15 deletions

View File

@@ -122,7 +122,7 @@ func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) {
authInfo = &AuthInfo{ authInfo = &AuthInfo{
AuthBindInfo: authBindInfo, AuthBindInfo: authBindInfo,
LoginTime: time.Now(), LoginTime: time.Now(),
ExpiresIn: time.Now().Add(DefTokenDuration).Unix(), ExpiresAt: time.Now().Add(DefTokenDuration).Unix(),
Token: token, Token: token,
TokenType: tokenType, 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)) globals.SugarLogger.Debugf("createAuthInfo id:%s, id2:%s, mobile:%s, authInfo:%s", authInfo.GetID(), authInfo.GetID2(), authInfo.GetMobile(), utils.Format4Output(authInfo, true))
} else { } else {
expireDuration = TmpTokenDuration 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)) globals.SugarLogger.Debugf("createAuthInfo authInfo:%s", utils.Format4Output(authInfo, true))
} }
SetUserInfo(token, authInfo, expireDuration) SetUserInfo(token, authInfo, expireDuration)

View File

@@ -13,11 +13,11 @@ const (
) )
type UserBasic struct { type UserBasic struct {
UserID string UserID string `json:"userID"`
UserID2 string UserID2 string `json:"userID2"`
Mobile string Mobile string `json:"mobile"`
Email string Email string `json:"email"`
Name string Name string `json:"name"`
} }
func (u *UserBasic) GetID() string { func (u *UserBasic) GetID() string {
@@ -55,18 +55,18 @@ func (u *UserBasic) IsUserEmpty() bool {
type AuthBindEx struct { type AuthBindEx struct {
model.AuthBind model.AuthBind
UserData interface{} // 认证成功后得到的原始用户信息 UserData interface{} `json:"userData"` // 认证成功后得到的原始用户信息
UserHint *UserBasic // 认证成功后得到的一些可能的基本用户信息主要有用信息是手机号email与用户名 UserHint *UserBasic `json:"userHint"` // 认证成功后得到的一些可能的基本用户信息主要有用信息是手机号email与用户名
} }
type AuthInfo struct { type AuthInfo struct {
UserBasic // 登录成功后保存的用户信息 UserBasic // 登录成功后保存的用户信息
AuthBindInfo *AuthBindEx AuthBindInfo *AuthBindEx `json:"authBindInfo"`
LoginTime time.Time LoginTime time.Time `json:"loginTime"`
ExpiresIn int64 ExpiresAt int64 `json:"expiresAt"`
Token string Token string `json:"token"`
TokenType int // TOKEN类型 TokenType int `json:"tokenType"` // TOKEN类型
} }
func (a *AuthInfo) GetAuthID() string { func (a *AuthInfo) GetAuthID() string {