...
|
...
|
@@ -23,6 +23,13 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{ |
|
|
result interface{}
|
|
|
err error
|
|
|
)
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
_, err = creationUserGateway.AuthRefreshIM(allied_creation_user.ReqAuthRefreshIM{
|
|
|
Phone: loginCommand.Phone,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "系统错误")
|
|
|
}
|
|
|
switch loginCommand.GrantType {
|
|
|
case "signInPassword":
|
|
|
result, err = srv.SignInPassword(loginCommand.Phone, loginCommand.Password)
|
...
|
...
|
@@ -88,7 +95,7 @@ func (srv AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke |
|
|
if err := accessTokenCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
ltoken := domain.LoginToken{}
|
|
|
ltoken := &domain.LoginToken{}
|
|
|
err := ltoken.ParseToken(accessTokenCommand.AuthCode)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -96,6 +103,7 @@ func (srv AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke |
|
|
phone := ltoken.Account
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
userSeachResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
|
|
|
CompanyId: ltoken.CompanyId,
|
|
|
Phone: phone,
|
|
|
})
|
|
|
if err != nil {
|
...
|
...
|
@@ -137,7 +145,7 @@ func (srv AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke |
|
|
UserId: int64(userSeachResult.Users[0].UserId),
|
|
|
Account: userSeachResult.Users[0].UserInfo.Phone,
|
|
|
Platform: domain.LoginPlatformApp,
|
|
|
CompanyId: int64(userSeachResult.Users[0].Company.CompanyId),
|
|
|
//CompanyId: int64(userSeachResult.Users[0].Company.CompanyId),
|
|
|
OrganizationId: int64(userSeachResult.Users[0].Org.OrgId),
|
|
|
AccessToken: "",
|
|
|
RefreshToken: "",
|
...
|
...
|
@@ -146,6 +154,9 @@ func (srv AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke |
|
|
CreatedTime: time.Now(),
|
|
|
UpdatedTime: time.Now(),
|
|
|
}
|
|
|
if userSeachResult.Users[0].Company != nil {
|
|
|
currentAccess.CompanyId = int64(userSeachResult.Users[0].Company.CompanyId)
|
|
|
}
|
|
|
}
|
|
|
//判定当前凭证的companyId,OrganizationId 是否在用户列表中
|
|
|
var currentOrgIsOK bool
|
...
|
...
|
@@ -343,6 +354,8 @@ func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (in |
|
|
"userName": resultUser.UserInfo.UserName,
|
|
|
"userPhone": resultUser.UserInfo.Phone,
|
|
|
"userAvatar": resultUser.UserInfo.Avatar,
|
|
|
//"userCode": resultUser.UserInfo.UserCode,
|
|
|
"email": resultUser.UserInfo.Email,
|
|
|
},
|
|
|
"department": resultUser.Department,
|
|
|
"company": map[string]interface{}{
|
...
|
...
|
|