作者 yangfu

修改:centerCompanys 增加凭证登录

... ... @@ -301,6 +301,11 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
return
}
break
case protocol.LoginByCredentials:
if _, err = utils.ParseJWTToken(request.Credentials); err != nil {
err = protocol.NewErrWithMessage(4140, err)
return
}
default:
err = protocol.NewCustomMessage(1, "登录方式不支持!")
break
... ...
... ... @@ -2,6 +2,7 @@ package domain_service
import (
"github.com/tiptok/gocomm/xa/eda"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
... ... @@ -154,8 +155,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
return response, nil
}
var (
companyList []*domain.Company
//adminApiGateway = http_gateway.NewHttplibBusinessAdminApiServiceGateway()
companyList []*domain.Company
adminApiGateway = http_gateway.NewHttplibBusinessAdminApiServiceGateway()
)
doGetCompanyIds := func() []int64 {
var companies []int64
... ... @@ -169,22 +170,24 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
for i := range companyList {
c := companyList[i]
//通过企业平台 校验模块权限
//var user *domain.Users
//for j := range svr.Users {
// if svr.Users[j].CompanyId == c.Id {
// user = svr.Users[j]
// break
// }
//}
//if user != nil {
// if code, e := adminApiGateway.UserAuth(user.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
// log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e.Error())
// continue
// } else {
// log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e)
// }
//}
if constant.POSTGRESQL_DB_NAME != "partner_dev" {
//通过企业平台 校验模块权限
var user *domain.Users
for j := range svr.Users {
if svr.Users[j].CompanyId == c.Id {
user = svr.Users[j]
break
}
}
if user != nil {
if code, e := adminApiGateway.UserAuth(user.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e.Error())
continue
} else {
log.Debug("【检查权限】", svr.Phone, "【公司】", c.Id, user.Id, code, e)
}
}
}
item := newCompanyBase(c)
companys = append(companys, item)
}
... ...
package protocol
const (
LoginByPassword = "signInPassword"
LoginBySmsCode = "signInCaptcha"
LoginByPassword = "signInPassword"
LoginBySmsCode = "signInCaptcha"
LoginByCredentials = "signInCredentials"
)
const AuthCodeExpire = 60 * 15 //15分钟过期
... ... @@ -15,11 +16,12 @@ const RefreshTokenExipre = 3600 * 24 * 30 * 1 //刷新token 一个月过期
/*Login */
type LoginRequest struct {
Phone string `json:"phone" valid:"Required;"`
Password string `json:"password"`
Captcha string `json:"captcha"`
GrantType string `json:"grantType"` // 登录类型 1:密码 2:验证码
ClientId string `json:"clientId"`
Phone string `json:"phone" valid:"Required;"`
Password string `json:"password"`
Captcha string `json:"captcha"`
GrantType string `json:"grantType"` // 登录类型 1:密码 2:验证码
ClientId string `json:"clientId"`
Credentials string `json:"credentials"` //凭证登录
}
type LoginResponse struct {
AuthCode string `json:"authCode"`
... ...