- 添加用户最后登录信息

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

@@ -3,6 +3,7 @@ package cms
import (
"errors"
"fmt"
"time"
"git.rosy.net.cn/baseapi/utils/errlist"
@@ -87,6 +88,17 @@ func (*UserProvider) UpdateUserType(userID string, userTypeMask int8, updateType
return err
}
func (*UserProvider) UpdateLastLogin(userID string, lastLoginType, fromIP string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"LastLoginAt": utils.Time2Pointer(time.Now()),
"LastLoginType": lastLoginType,
"LastLoginIP": fromIP,
}, model.AdminName, map[string]interface{}{
"UserID": userID,
})
return err
}
// func (*UserProvider) CreateUser(userID2, mobile, email, name string) (user auth2.IUser, err error) {
// realUser := &model.User{
// UserID2: userID2,
@@ -102,7 +114,7 @@ func init() {
}
func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVerifyCode string, inAuthInfo *auth2.AuthInfo) (outAuthInfo *auth2.AuthInfo, err error) {
mobileAuth, err2 := auth2.Login(auth2.AuthTypeMobile, user.GetMobile(), auth2.UserIDMobile, mobileVerifyCode)
mobileAuth, err2 := auth2.Login(ctx.Context, auth2.AuthTypeMobile, user.GetMobile(), auth2.UserIDMobile, mobileVerifyCode)
if err = err2; err == nil {
if !mobileAuth.IsUserEmpty() {
return nil, jsonerr.New(mobileAuth, model.ErrCodeJsonUserAlreadyExist)