作者 yangfu

修改:centerCompanys 增加凭证登录

@@ -301,6 +301,11 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -301,6 +301,11 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
301 return 301 return
302 } 302 }
303 break 303 break
  304 + case protocol.LoginByCredentials:
  305 + if _, err = utils.ParseJWTToken(request.Credentials); err != nil {
  306 + err = protocol.NewErrWithMessage(4140, err)
  307 + return
  308 + }
304 default: 309 default:
305 err = protocol.NewCustomMessage(1, "登录方式不支持!") 310 err = protocol.NewCustomMessage(1, "登录方式不支持!")
306 break 311 break
@@ -2,6 +2,7 @@ package domain_service @@ -2,6 +2,7 @@ package domain_service
2 2
3 import ( 3 import (
4 "github.com/tiptok/gocomm/xa/eda" 4 "github.com/tiptok/gocomm/xa/eda"
  5 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
@@ -154,8 +155,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { @@ -154,8 +155,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
154 return response, nil 155 return response, nil
155 } 156 }
156 var ( 157 var (
157 - companyList []*domain.Company  
158 - //adminApiGateway = http_gateway.NewHttplibBusinessAdminApiServiceGateway() 158 + companyList []*domain.Company
  159 + adminApiGateway = http_gateway.NewHttplibBusinessAdminApiServiceGateway()
159 ) 160 )
160 doGetCompanyIds := func() []int64 { 161 doGetCompanyIds := func() []int64 {
161 var companies []int64 162 var companies []int64
@@ -169,22 +170,24 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { @@ -169,22 +170,24 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
169 for i := range companyList { 170 for i := range companyList {
170 c := companyList[i] 171 c := companyList[i]
171 172
172 - //通过企业平台 校验模块权限  
173 - //var user *domain.Users  
174 - //for j := range svr.Users {  
175 - // if svr.Users[j].CompanyId == c.Id {  
176 - // user = svr.Users[j]  
177 - // break  
178 - // }  
179 - //}  
180 - //if user != nil {  
181 - // if code, e := adminApiGateway.UserAuth(user.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {  
182 - // log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e.Error())  
183 - // continue  
184 - // } else {  
185 - // log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e)  
186 - // }  
187 - //} 173 + if constant.POSTGRESQL_DB_NAME != "partner_dev" {
  174 + //通过企业平台 校验模块权限
  175 + var user *domain.Users
  176 + for j := range svr.Users {
  177 + if svr.Users[j].CompanyId == c.Id {
  178 + user = svr.Users[j]
  179 + break
  180 + }
  181 + }
  182 + if user != nil {
  183 + if code, e := adminApiGateway.UserAuth(user.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
  184 + log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e.Error())
  185 + continue
  186 + } else {
  187 + log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e)
  188 + }
  189 + }
  190 + }
188 item := newCompanyBase(c) 191 item := newCompanyBase(c)
189 companys = append(companys, item) 192 companys = append(companys, item)
190 } 193 }
1 package protocol 1 package protocol
2 2
3 const ( 3 const (
4 - LoginByPassword = "signInPassword"  
5 - LoginBySmsCode = "signInCaptcha" 4 + LoginByPassword = "signInPassword"
  5 + LoginBySmsCode = "signInCaptcha"
  6 + LoginByCredentials = "signInCredentials"
6 ) 7 )
7 8
8 const AuthCodeExpire = 60 * 15 //15分钟过期 9 const AuthCodeExpire = 60 * 15 //15分钟过期
@@ -15,11 +16,12 @@ const RefreshTokenExipre = 3600 * 24 * 30 * 1 //刷新token 一个月过期 @@ -15,11 +16,12 @@ const RefreshTokenExipre = 3600 * 24 * 30 * 1 //刷新token 一个月过期
15 16
16 /*Login */ 17 /*Login */
17 type LoginRequest struct { 18 type LoginRequest struct {
18 - Phone string `json:"phone" valid:"Required;"`  
19 - Password string `json:"password"`  
20 - Captcha string `json:"captcha"`  
21 - GrantType string `json:"grantType"` // 登录类型 1:密码 2:验证码  
22 - ClientId string `json:"clientId"` 19 + Phone string `json:"phone" valid:"Required;"`
  20 + Password string `json:"password"`
  21 + Captcha string `json:"captcha"`
  22 + GrantType string `json:"grantType"` // 登录类型 1:密码 2:验证码
  23 + ClientId string `json:"clientId"`
  24 + Credentials string `json:"credentials"` //凭证登录
23 } 25 }
24 type LoginResponse struct { 26 type LoginResponse struct {
25 AuthCode string `json:"authCode"` 27 AuthCode string `json:"authCode"`