作者 陈志颖

feat:增加修改密码时多密码判断

  1 +# Config file for [Air](https://github.com/cosmtrek/air) in TOML format
  2 +
  3 +# Working directory
  4 +# . or absolute path, please note that the directories following must be under root.
  5 +root = "."
  6 +tmp_dir = "tmp"
  7 +
  8 +[build]
  9 +# Just plain old shell command. You could use `make` as well.
  10 +cmd = "go build -o ./tmp/main ."
  11 +# Binary file yields from `cmd`.
  12 +bin = "tmp/main"
  13 +# Customize binary.
  14 +full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
  15 +# Watch these filename extensions.
  16 +include_ext = ["go", "tpl", "tmpl", "html"]
  17 +# Ignore these filename extensions or directories.
  18 +exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
  19 +# Watch these directories if you specified.
  20 +include_dir = []
  21 +# Exclude files.
  22 +exclude_file = []
  23 +# Exclude unchanged files.
  24 +exclude_unchanged = true
  25 +# This log file places in your tmp_dir.
  26 +log = "air.log"
  27 +# It's not necessary to trigger build each time file changes if it's too frequent.
  28 +delay = 1000 # ms
  29 +# Stop running old binary when build errors occur.
  30 +stop_on_error = true
  31 +# Send Interrupt signal before killing process (windows does not support this feature)
  32 +send_interrupt = false
  33 +# Delay after sending Interrupt signal
  34 +kill_delay = 500 # ms
  35 +
  36 +[log]
  37 +# Show log time
  38 +time = false
  39 +
  40 +[color]
  41 +# Customize each part's color. If no color found, use the raw app log.
  42 +main = "magenta"
  43 +watcher = "cyan"
  44 +build = "yellow"
  45 +runner = "green"
  46 +
  47 +[misc]
  48 +# Delete tmp directory on exit
  49 +clean_on_exit = true
@@ -302,7 +302,13 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol. @@ -302,7 +302,13 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
302 return 302 return
303 } 303 }
304 304
305 -// 企业平台-密码校验 305 +/**
  306 + * @Author SteveChan
  307 + * @Description 企业平台-密码登录校验
  308 + * @Date 11:06 2021/2/5
  309 + * @Param
  310 + * @return
  311 + **/
306 func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginRequest) (v interface{}, err error) { 312 func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginRequest) (v interface{}, err error) {
307 var ( 313 var (
308 transactionContext, _ = factory.CreateTransactionContext(nil) 314 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -346,7 +352,7 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques @@ -346,7 +352,7 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques
346 352
347 /** 353 /**
348 * @Author SteveChan 354 * @Author SteveChan
349 - * @Description // 企业平台-多公司登录,判断是否高管 355 + * @Description //TODO 企业平台-多公司登录,判断是否高管,优化游客登录
350 * @Date 15:01 2021/1/12 356 * @Date 15:01 2021/1/12
351 * @Param 357 * @Param
352 * @return 358 * @return
@@ -369,14 +375,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -369,14 +375,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
369 375
370 rsp := &protocolx.CenterCompanysResponse{} 376 rsp := &protocolx.CenterCompanysResponse{}
371 377
372 - // 启动事务  
373 if err = transactionContext.StartTransaction(); err != nil { 378 if err = transactionContext.StartTransaction(); err != nil {
374 log.Error(err) 379 log.Error(err)
375 return nil, err 380 return nil, err
376 } 381 }
377 382
378 defer func() { 383 defer func() {
379 - transactionContext.RollbackTransaction() 384 + _ = transactionContext.RollbackTransaction()
380 }() 385 }()
381 386
382 // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去 387 // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
@@ -490,7 +495,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -490,7 +495,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
490 495
491 /** 496 /**
492 * @Author SteveChan 497 * @Author SteveChan
493 - * @Description // 企业平台-多公司登录 - 通过凭证,判断是否高管 498 + * @Description //TODO 企业平台-多公司登录 - 通过凭证,判断是否高管
494 * @Date 15:00 2021/1/12 499 * @Date 15:00 2021/1/12
495 * @Param 500 * @Param
496 * @return 501 * @return
@@ -555,7 +560,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco @@ -555,7 +560,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
555 560
556 /** 561 /**
557 * @Author SteveChan 562 * @Author SteveChan
558 - * @Description //TODO 登录 563 + * @Description 登录
559 * @Date 15:05 2021/1/15 564 * @Date 15:05 2021/1/15
560 * @Param 565 * @Param
561 * @return 566 * @return
@@ -575,7 +580,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -575,7 +580,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
575 return nil, err 580 return nil, err
576 } 581 }
577 defer func() { 582 defer func() {
578 - transactionContext.RollbackTransaction() 583 + _ = transactionContext.RollbackTransaction()
579 }() 584 }()
580 if claim, err = utils.ParseJWTToken(request.Credentials); err != nil { 585 if claim, err = utils.ParseJWTToken(request.Credentials); err != nil {
581 err = protocol.NewErrWithMessage(4140, err) 586 err = protocol.NewErrWithMessage(4140, err)
@@ -66,6 +66,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -66,6 +66,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
66 //if request.EndTime > last.Unix()*1000 { 66 //if request.EndTime > last.Unix()*1000 {
67 // request.EndTime = last.Unix() * 1000 67 // request.EndTime = last.Unix() * 1000
68 //} 68 //}
  69 +
69 fmt.Print("StartTime: ", request.StartTime, "\n") 70 fmt.Print("StartTime: ", request.StartTime, "\n")
70 fmt.Print("EndTime: ", request.EndTime, "\n") 71 fmt.Print("EndTime: ", request.EndTime, "\n")
71 72
@@ -44,20 +44,53 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone @@ -44,20 +44,53 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone
44 } 44 }
45 return 45 return
46 } 46 }
  47 +
  48 +/**
  49 + * @Author SteveChan
  50 + * @Description 密码校验增加多公司
  51 + * @Date 11:52 2021/2/7
  52 + * @Param
  53 + * @return
  54 + **/
47 func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, phone string) (err error) { 55 func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, phone string) (err error) {
48 var ( 56 var (
49 - partnerInfo *domain.PartnerInfo 57 + //partnerInfo *domain.PartnerInfo
  58 + partnerInfos []*domain.PartnerInfo
50 PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext) 59 PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext)
51 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext) 60 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
52 ) 61 )
53 - if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil { 62 +
  63 + // 查询账号信息
  64 + if _, partnerInfos, err = PartnerInfoService.Find(map[string]interface{}{"account": phone}); err != nil {
54 err = errUserNotFound //账号不存在 65 err = errUserNotFound //账号不存在
55 return 66 return
56 } 67 }
57 - if !strings.EqualFold(partnerInfo.Password, oldPwd) { 68 +
  69 + //多公司密码校验
  70 + var misMatch bool
  71 + for _, partnerInfo := range partnerInfos {
  72 + if !strings.EqualFold(partnerInfo.Password, oldPwd) {
  73 + misMatch = true
  74 + } else {
  75 + misMatch = false
  76 + break
  77 + }
  78 + }
  79 +
  80 + if misMatch {
58 err = fmt.Errorf("旧密码不正确") //账号不存在 81 err = fmt.Errorf("旧密码不正确") //账号不存在
59 return 82 return
60 } 83 }
  84 +
  85 + //if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil {
  86 + // err = errUserNotFound //账号不存在
  87 + // return
  88 + //}
  89 + //if !strings.EqualFold(partnerInfo.Password, oldPwd) {
  90 + // err = fmt.Errorf("旧密码不正确") //账号不存在
  91 + // return
  92 + //}
  93 +
61 if err = PartnerInfoDao.Update(map[string]interface{}{ 94 if err = PartnerInfoDao.Update(map[string]interface{}{
62 "oldAccount": phone, 95 "oldAccount": phone,
63 "Password": newPwd, 96 "Password": newPwd,
不能预览此文件类型