|
@@ -284,6 +284,9 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol. |
|
@@ -284,6 +284,9 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol. |
284
|
err = nil
|
284
|
err = nil
|
285
|
return
|
285
|
return
|
286
|
}
|
286
|
}
|
|
|
287
|
+ //注销凭证
|
|
|
288
|
+ userAuth.NewRedisUserCredential(user.Phone).RemoveAuth()
|
|
|
289
|
+ //注销token
|
287
|
id, _ := strconv.Atoi(user.Phone)
|
290
|
id, _ := strconv.Atoi(user.Phone)
|
288
|
auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id)))
|
291
|
auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(id)))
|
289
|
if !auth.Exist() {
|
292
|
if !auth.Exist() {
|
|
@@ -339,6 +342,12 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -339,6 +342,12 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
339
|
}
|
342
|
}
|
340
|
break
|
343
|
break
|
341
|
case protocol.LoginByCredentials:
|
344
|
case protocol.LoginByCredentials:
|
|
|
345
|
+ //凭证是否存在
|
|
|
346
|
+ if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
|
347
|
+ log.Debug("凭证过期或者已失效:", request.Phone)
|
|
|
348
|
+ err = protocol.NewErrWithMessage(4140, err)
|
|
|
349
|
+ return
|
|
|
350
|
+ }
|
342
|
if _, err = utils.ParseJWTToken(request.Credentials); err != nil {
|
351
|
if _, err = utils.ParseJWTToken(request.Credentials); err != nil {
|
343
|
err = protocol.NewErrWithMessage(4140, err)
|
352
|
err = protocol.NewErrWithMessage(4140, err)
|
344
|
return
|
353
|
return
|
|
@@ -375,6 +384,9 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -375,6 +384,9 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
375
|
rsp.Phone = request.Phone
|
384
|
rsp.Phone = request.Phone
|
376
|
rsp.Credentials, _ = utils.GenerateToken(int64(phoneId), request.Phone, protocol.RefreshTokenExipre*time.Second)
|
385
|
rsp.Credentials, _ = utils.GenerateToken(int64(phoneId), request.Phone, protocol.RefreshTokenExipre*time.Second)
|
377
|
|
386
|
|
|
|
387
|
+ //添加手机对应的凭证
|
|
|
388
|
+ userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
|
|
|
389
|
+
|
378
|
err = transactionContext.CommitTransaction()
|
390
|
err = transactionContext.CommitTransaction()
|
379
|
v = map[string]interface{}{"center": rsp}
|
391
|
v = map[string]interface{}{"center": rsp}
|
380
|
return
|
392
|
return
|
|
@@ -398,6 +410,12 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
|
@@ -398,6 +410,12 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
398
|
err = protocol.NewErrWithMessage(4140, err)
|
410
|
err = protocol.NewErrWithMessage(4140, err)
|
399
|
return
|
411
|
return
|
400
|
}
|
412
|
}
|
|
|
413
|
+ //凭证是否存在
|
|
|
414
|
+ if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
|
415
|
+ log.Debug("凭证过期或者已失效:", claim.Phone)
|
|
|
416
|
+ err = protocol.NewErrWithMessage(4140, err)
|
|
|
417
|
+ return
|
|
|
418
|
+ }
|
401
|
loginSvr.Init(claim.Phone)
|
419
|
loginSvr.Init(claim.Phone)
|
402
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
420
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
403
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
421
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
|
@@ -406,6 +424,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
|
@@ -406,6 +424,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
406
|
err = protocol.NewErrWithMessage(4140, err) //账号禁用
|
424
|
err = protocol.NewErrWithMessage(4140, err) //账号禁用
|
407
|
return
|
425
|
return
|
408
|
}
|
426
|
}
|
|
|
427
|
+
|
409
|
err = transactionContext.CommitTransaction()
|
428
|
err = transactionContext.CommitTransaction()
|
410
|
return
|
429
|
return
|
411
|
}
|
430
|
}
|
|
@@ -431,6 +450,12 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
@@ -431,6 +450,12 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
431
|
err = protocol.NewErrWithMessage(4140, err)
|
450
|
err = protocol.NewErrWithMessage(4140, err)
|
432
|
return
|
451
|
return
|
433
|
}
|
452
|
}
|
|
|
453
|
+ //凭证是否存在
|
|
|
454
|
+ if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
|
455
|
+ log.Debug("凭证过期或者已失效:", claim.Phone)
|
|
|
456
|
+ err = protocol.NewErrWithMessage(4140, err)
|
|
|
457
|
+ return
|
|
|
458
|
+ }
|
434
|
if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil {
|
459
|
if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil {
|
435
|
err = protocol.NewErrWithMessage(10007, err)
|
460
|
err = protocol.NewErrWithMessage(10007, err)
|
436
|
return
|
461
|
return
|
|
@@ -444,8 +469,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
@@ -444,8 +469,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
444
|
return
|
469
|
return
|
445
|
}
|
470
|
}
|
446
|
}
|
471
|
}
|
447
|
- //TODO:验证公司模块权限
|
|
|
448
|
- if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2}); e == nil {
|
472
|
+ //验证公司模块权限
|
|
|
473
|
+ if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2, "deleteAtIsNull": true}); e == nil {
|
449
|
if len(adminUsers) > 0 {
|
474
|
if len(adminUsers) > 0 {
|
450
|
au := adminUsers[0]
|
475
|
au := adminUsers[0]
|
451
|
if code, e := adminApiGateway.UserAuth(au.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
|
476
|
if code, e := adminApiGateway.UserAuth(au.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
|