...
|
...
|
@@ -8,7 +8,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
//登录
|
|
|
func Login(request *protocol.LoginRequest)(rsp *protocol.LoginResponse,err error){
|
|
|
var (
|
|
|
user *models.Users
|
...
|
...
|
@@ -17,12 +17,16 @@ func Login(request *protocol.LoginRequest)(rsp *protocol.LoginResponse,err error |
|
|
user,err =models.GetUsersByMobile(request.Phone)
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
err =common.NewError(2020,err)//账号不存在
|
|
|
return
|
|
|
}
|
|
|
switch request.GrantType {
|
|
|
case protocol.LoginPassPord:
|
|
|
if strings.Compare(user.Password,request.PassWord)==0{
|
|
|
goto Success
|
|
|
}else{
|
|
|
err =common.NewError(2021,err)//登录密码错误
|
|
|
return
|
|
|
}
|
|
|
break
|
|
|
case protocol.LoginSmdcode:
|
...
|
...
|
@@ -43,16 +47,16 @@ func Login(request *protocol.LoginRequest)(rsp *protocol.LoginResponse,err error |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//短信验证码
|
|
|
func SmsCode(request *protocol.SmsCodeRequest)(rsp *protocol.SmsCodeResponse,err error){
|
|
|
return nil,nil
|
|
|
}
|
|
|
|
|
|
//更新设备信息
|
|
|
func UpdateDevice(request *protocol.UpdateDeviceRequest)(rsp *protocol.UpdateDeviceResponse,err error){
|
|
|
return nil,nil
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取accessToken
|
|
|
func AccessToken(request *protocol.AccessTokenRequest)(rsp *protocol.AccessTokenResponse,err error){
|
|
|
var (
|
|
|
userInfo *models.UserInfo
|
...
|
...
|
@@ -73,7 +77,7 @@ func AccessToken(request *protocol.AccessTokenRequest)(rsp *protocol.AccessToken |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//刷新token
|
|
|
func RefreshToken(request *protocol.RefreshTokenRequest)(rsp *protocol.RefreshTokenResponse,err error){
|
|
|
var (
|
|
|
userInfo *models.UserInfo
|
...
|
...
|
@@ -87,7 +91,8 @@ func RefreshToken(request *protocol.RefreshTokenRequest)(rsp *protocol.RefreshTo |
|
|
err = common.NewErrorWithMsg(2,"refresh token error.")
|
|
|
return
|
|
|
}
|
|
|
if newAccess,err =refreshToken(userInfo.Id,"");err!=nil{
|
|
|
request.Uid,request.LoginType = userInfo.Id,"mobile"
|
|
|
if newAccess,err =refreshToken(request);err!=nil{
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.RefreshTokenResponse{
|
...
|
...
|
@@ -97,12 +102,14 @@ func RefreshToken(request *protocol.RefreshTokenRequest)(rsp *protocol.RefreshTo |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//loginType mobile im
|
|
|
func refreshToken(uid int64,loginType string)(rsp *protocol.Access,err error){
|
|
|
//刷新token loginType mobile im web
|
|
|
func refreshToken(request *protocol.RefreshTokenRequest)(rsp *protocol.Access,err error){
|
|
|
if request.Uid==0{
|
|
|
return
|
|
|
}
|
|
|
return nil,nil
|
|
|
}
|
|
|
|
|
|
//检查token有效性
|
|
|
func CheckToken(request *protocol.CheckTokenRequest)(rsp *protocol.CheckTokenResponse,err error){
|
|
|
var (
|
|
|
userInfo *models.UserInfo
|
...
|
...
|
@@ -122,7 +129,7 @@ func CheckToken(request *protocol.CheckTokenRequest)(rsp *protocol.CheckTokenRes |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//检查uuid 是否重复
|
|
|
func CheckUuid(request *protocol.CheckUuidRequest)(rsp *protocol.CheckUuidResponse,err error){
|
|
|
var (
|
|
|
logUuid *models.LogUuid
|
...
|
...
|
|