...
|
...
|
@@ -112,6 +112,73 @@ Success: |
|
|
return
|
|
|
}
|
|
|
|
|
|
func (s *AuthService) Login1(request *protocol.LoginRequest) (rsp *protocol.LoginResponse, err error) {
|
|
|
var logintype ILoginAuth
|
|
|
switch request.GrantType {
|
|
|
case protocol.LoginTypePassPord:
|
|
|
logintype = NewLoginByPassword(request.Phone, request.PassWord)
|
|
|
case protocol.LoginTypeSmdcode:
|
|
|
logintype = NewLoginBySms(request.Phone, request.Code)
|
|
|
default:
|
|
|
err = fmt.Errorf("grantType error:%s", request.GrantType)
|
|
|
return
|
|
|
}
|
|
|
var useridentity *UserIdentity
|
|
|
useridentity, err = logintype.LoginAuth()
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(useridentity.Auth) == 0 {
|
|
|
useridentity.Auth = uid.NewV1().StringNoDash()
|
|
|
}
|
|
|
if len(useridentity.Imtoken) == 0 {
|
|
|
//usercreate 最多重试俩次
|
|
|
for i := 0; i < 2; i++ {
|
|
|
v := s_im.UserCreate{
|
|
|
Accid: fmt.Sprintf("%s", useridentity.Uid),
|
|
|
Name: useridentity.Uname,
|
|
|
Icon: useridentity.Icon,
|
|
|
}
|
|
|
tokenInfo, err := s_im.ParseUserCreate(v)
|
|
|
if err != nil {
|
|
|
log.Error("s_im.ParseUserCreate err:", err)
|
|
|
}
|
|
|
if err == nil {
|
|
|
if tokenInfo.Code == 200 {
|
|
|
useridentity.Imtoken = tokenInfo.Info.Token
|
|
|
// 跳出
|
|
|
break
|
|
|
} else {
|
|
|
log.Error("s_im.ParseUserCreate response code:", tokenInfo.Code)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
//userupdateunifo
|
|
|
for i := 0; i < 2; i++ {
|
|
|
v := s_im.UserUpdateUinfo{
|
|
|
Accid: fmt.Sprintf("%s", useridentity.Accid),
|
|
|
Name: useridentity.Uname,
|
|
|
Icon: useridentity.Icon,
|
|
|
}
|
|
|
rsp, err := s_im.ParseUserUpdateUinfo(v)
|
|
|
if err != nil {
|
|
|
log.Error("s_im.ParseUserUpdateUinfo err:", err)
|
|
|
}
|
|
|
if err == nil {
|
|
|
if rsp.Code == 200 {
|
|
|
break
|
|
|
} else {
|
|
|
log.Error("s_im.ParseUserUpdateUinfo response code:", rsp.Code)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
//更新设备信息
|
|
|
func (s *AuthService) UpdateDevice(request *protocol.UpdateDeviceRequest) (rsp *protocol.UpdateDeviceResponse, err error) {
|
|
|
return nil, nil
|
...
|
...
|
@@ -357,7 +424,7 @@ func imUserCreate(request *protocol.CheckImRequest, rsp *protocol.CheckImRespons |
|
|
Icon: request.Icon,
|
|
|
}
|
|
|
resp []byte
|
|
|
out s_im.UserCreateResult
|
|
|
out s_im.UserTokenResult
|
|
|
)
|
|
|
if resp, err = s_im.DefaultImClient.Call(param); err != nil {
|
|
|
return
|
...
|
...
|
@@ -402,7 +469,7 @@ func imUserRefreshToken(request *protocol.CheckImRequest, rsp *protocol.CheckImR |
|
|
Accid: request.Uid,
|
|
|
}
|
|
|
resp []byte
|
|
|
out s_im.UserCreateResult
|
|
|
out s_im.UserTokenResult
|
|
|
)
|
|
|
if resp, err = s_im.DefaultImClient.Call(param); err != nil {
|
|
|
return
|
...
|
...
|
|