- 添加用户最后登录信息

This commit is contained in:
gazebo
2019-09-24 18:09:32 +08:00
parent 412b11396a
commit bf86235ce2
4 changed files with 35 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ type IUserProvider interface {
UpdateUserMobile(userID string, mobile string) (err error)
UpdateUserEmail(userID string, email string) (err error)
UpdateUserType(userID string, userTypeMask int8, updateType int) (err error)
UpdateLastLogin(userID string, lastLoginType, fromIP string) (err error)
// CreateUser(userID2, mobile, email, name string) (user IUser, err error)
}
@@ -222,7 +223,7 @@ func SendVerifyCode(authToken, captchaID, captchaValue, authID string) (err erro
// 公众号登录authIDTypeD是UserIDEmptyauthSecret是code这个函数是被微信的回调调用不是直接被客户端调用
// 微信登录authIDType是UserIDEmptyauthSecret是code这个函数是被微信的回调调用不是直接被客户端调用
// 小程序登录authIDType是UserIDEmptyauthSecret是jsCode
func Login(authType, authID, authIDType, authSecret string) (authInfo *AuthInfo, err error) {
func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authInfo *AuthInfo, err error) {
authType = strings.ToLower(authType)
authIDType = strings.ToLower(authIDType)
if handler := authers[authType]; handler != nil {
@@ -266,6 +267,9 @@ func Login(authType, authID, authIDType, authSecret string) (authInfo *AuthInfo,
}
}
authInfo = createAuthInfo(user, authBindEx)
if user != nil && user.GetID() != "" {
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
}
}
} else {
err = ErrIllegalAuthType