作者 yangfu

Merge remote-tracking branch 'origin/dev' into test

... ... @@ -81,6 +81,18 @@ spec:
configMapKeyRef:
name: suplus-config
key: service.businessadmin
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
... ... @@ -81,6 +81,18 @@ spec:
configMapKeyRef:
name: suplus-config
key: service.businessadmin
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
... ... @@ -81,6 +81,18 @@ spec:
configMapKeyRef:
name: suplus-config
key: service.businessadmin
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
... ... @@ -6,7 +6,6 @@ require (
github.com/astaxie/beego v1.12.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gin-gonic/gin v1.5.0
github.com/go-pg/pg v8.0.6+incompatible
github.com/go-pg/pg/v10 v10.0.0-beta.2
github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
... ...
... ... @@ -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
... ... @@ -330,6 +335,7 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
rsp.CsAccountID = fmt.Sprintf("%v", imInfo.CustomerImId)
rsp.ImToken = imInfo.ImToken
rsp.Accid, _ = strconv.Atoi(imInfo.ImId)
rsp.Phone = request.Phone
rsp.Credentials, _ = utils.GenerateToken(int64(phoneId), request.Phone, protocol.RefreshTokenExipre*time.Second)
err = transactionContext.CommitTransaction()
... ... @@ -352,7 +358,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest
transactionContext.RollbackTransaction()
}()
if claim, err = utils.ParseJWTToken(request.Credentials); err != nil {
err = protocol.NewErrWithMessage(4139, err)
err = protocol.NewErrWithMessage(4140, err)
return
}
loginSvr.Init(claim.Phone)
... ...
... ... @@ -9,6 +9,7 @@ var REDIS_AUTH = "123456"
func init() {
if os.Getenv("REDIS_HOST") != "" {
REDIS_HOST = os.Getenv("REDIS_HOST")
REDIS_AUTH = os.Getenv("REDIS_AUTH")
}
if os.Getenv("REDIS_PORT") != "" {
REDIS_PORT = os.Getenv("REDIS_PORT")
... ...
... ... @@ -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"`
... ...
... ... @@ -5,6 +5,7 @@ type CenterCompanysResponse struct {
ImToken string `json:"imToken"` //网易云信Token
CsAccountID string `json:"csAccountID"` //系统分配客服ID
Credentials string `json:"credentials"` //登录凭证
Phone string `json:"phone"` //登录手机号
Partner interface{} `json:"partner"` //合伙人对象
Manager interface{} `json:"manager"` //高管对象
}
... ...