...
|
...
|
@@ -44,9 +44,9 @@ func assertImplement() { |
|
|
var (
|
|
|
//服务
|
|
|
sms s_sms.ISmsService = &s_sms.YunPianSmsService{}
|
|
|
ConfigRepository repository.IConfigRepository = &repository.ConfigRepository{}
|
|
|
//仓储
|
|
|
UserRepository repository.IUserRepository = &repository.UserRepository{}
|
|
|
//ConfigRepository repository.IConfigRepository = &repository.ConfigRepository{}
|
|
|
////仓储
|
|
|
//UserRepository repository.IUserRepository = &repository.UserRepository{}
|
|
|
)
|
|
|
|
|
|
//登录
|
...
|
...
|
@@ -57,7 +57,7 @@ func (s *AuthService) Login(request *protocol.LoginRequest) (rsp *protocol.Login |
|
|
result bool
|
|
|
checkImResponse *protocol.CheckImResponse
|
|
|
)
|
|
|
user, err = UserRepository.GetUsersByMobile(request.Phone)
|
|
|
user, err = repository.UserRepositoryFactory().GetUsersByMobile(request.Phone)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(2020, err) //账号不存在
|
...
|
...
|
@@ -84,7 +84,7 @@ func (s *AuthService) Login(request *protocol.LoginRequest) (rsp *protocol.Login |
|
|
}
|
|
|
Success:
|
|
|
{
|
|
|
userInfo, err = UserRepository.GetUserInfoByMobile(request.Phone)
|
|
|
userInfo, err = repository.UserRepositoryFactory().GetUserInfoByMobile(request.Phone)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
...
|
...
|
@@ -107,7 +107,7 @@ Success: |
|
|
userInfo.CsAccount = imGetRandomCSAccount()
|
|
|
}
|
|
|
userInfo.AuthExp = time.Now().Add(time.Second * protocol.TokenExpire)
|
|
|
if err = UserRepository.UpdateUserInfoById(userInfo); err != nil {
|
|
|
if err = repository.UserRepositoryFactory().UpdateUserInfoById(userInfo); err != nil {
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.LoginResponse{AuthCode: userInfo.Auth}
|
...
|
...
|
@@ -196,19 +196,19 @@ func (s *AuthService) AccessToken(request *protocol.AccessTokenRequest) (rsp *pr |
|
|
var (
|
|
|
userInfo *models.UserInfo
|
|
|
)
|
|
|
_, err = ConfigRepository.GetCfgClient(request.ClientId, request.ClientSecret)
|
|
|
_, err = repository.ConfigRepositoryFactory().GetCfgClient(request.ClientId, request.ClientSecret)
|
|
|
if err != nil {
|
|
|
err = protocol.NewErrWithMessage(101, err)
|
|
|
return
|
|
|
}
|
|
|
userInfo, err = UserRepository.GetUserInfoByAuthCode(request.AuthCode)
|
|
|
userInfo, err = repository.UserRepositoryFactory().GetUserInfoByAuthCode(request.AuthCode)
|
|
|
if err != nil {
|
|
|
err = protocol.NewErrWithMessage(4139, err)
|
|
|
return
|
|
|
}
|
|
|
userInfo.AccessToken = uid.NewV1().StringNoDash()
|
|
|
userInfo.RefreshToken = uid.NewV1().StringNoDash()
|
|
|
if err = UserRepository.UpdateUserInfoById(userInfo); err != nil {
|
|
|
if err = repository.UserRepositoryFactory().UpdateUserInfoById(userInfo); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -226,18 +226,18 @@ func (s *AuthService) RefreshToken(request *protocol.RefreshTokenRequest) (rsp * |
|
|
var (
|
|
|
userInfo *models.UserInfo
|
|
|
)
|
|
|
_, err = ConfigRepository.GetCfgClient(request.ClientId, request.ClientSecret)
|
|
|
_, err = repository.ConfigRepositoryFactory().GetCfgClient(request.ClientId, request.ClientSecret)
|
|
|
if err != nil {
|
|
|
protocol.NewErrWithMessage(101, err)
|
|
|
return
|
|
|
}
|
|
|
userInfo, err = UserRepository.GetUserInfoByRefreshToken(request.RefreshToken)
|
|
|
userInfo, err = repository.UserRepositoryFactory().GetUserInfoByRefreshToken(request.RefreshToken)
|
|
|
if err != nil {
|
|
|
protocol.NewErrWithMessage(4139, err)
|
|
|
return
|
|
|
}
|
|
|
userInfo.AccessToken = uid.NewV1().StringNoDash()
|
|
|
if err = UserRepository.UpdateUserInfoById(userInfo); err != nil {
|
|
|
if err = repository.UserRepositoryFactory().UpdateUserInfoById(userInfo); err != nil {
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.RefreshTokenResponse{
|
...
|
...
|
|