...
|
...
|
@@ -284,6 +284,9 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol. |
|
|
err = nil
|
|
|
return
|
|
|
}
|
|
|
//注销凭证
|
|
|
userAuth.NewRedisUserCredential(user.Phone).RemoveAuth()
|
|
|
//注销token
|
|
|
id, _ := strconv.Atoi(user.Phone)
|
|
|
auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id)))
|
|
|
if !auth.Exist() {
|
...
|
...
|
@@ -339,6 +342,12 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
}
|
|
|
break
|
|
|
case protocol.LoginByCredentials:
|
|
|
//凭证是否存在
|
|
|
if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
|
log.Debug("凭证过期或者已失效:", request.Phone)
|
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
|
|
}
|
|
|
if _, err = utils.ParseJWTToken(request.Credentials); err != nil {
|
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
...
|
...
|
@@ -375,6 +384,9 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
rsp.Phone = request.Phone
|
|
|
rsp.Credentials, _ = utils.GenerateToken(int64(phoneId), request.Phone, protocol.RefreshTokenExipre*time.Second)
|
|
|
|
|
|
//添加手机对应的凭证
|
|
|
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
|
|
|
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
return
|
...
|
...
|
@@ -398,6 +410,12 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
|
|
}
|
|
|
//凭证是否存在
|
|
|
if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
|
log.Debug("凭证过期或者已失效:", claim.Phone)
|
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
|
|
}
|
|
|
loginSvr.Init(claim.Phone)
|
|
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
|
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
...
|
...
|
@@ -406,6 +424,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
|
|
err = protocol.NewErrWithMessage(4140, err) //账号禁用
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -431,6 +450,12 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
|
|
}
|
|
|
//凭证是否存在
|
|
|
if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
|
log.Debug("凭证过期或者已失效:", claim.Phone)
|
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
|
|
}
|
|
|
if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil {
|
|
|
err = protocol.NewErrWithMessage(10007, err)
|
|
|
return
|
...
|
...
|
@@ -444,8 +469,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//TODO:验证公司模块权限
|
|
|
if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2}); e == nil {
|
|
|
//验证公司模块权限
|
|
|
if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2, "deleteAtIsNull": true}); e == nil {
|
|
|
if len(adminUsers) > 0 {
|
|
|
au := adminUsers[0]
|
|
|
if code, e := adminApiGateway.UserAuth(au.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
|
...
|
...
|
|