diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index 26ae8fa2..07c83931 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -32,7 +32,7 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeLoginWrongPswd: "登录密码错误", ErrCodeLoginWrongVeriCode: "验证码错误", ErrCodeLoginVeriCodeExpired: "验证码已过期", - ErrCodeLoginAcctLocked: "登录账户尝试爆破登录,已被锁定", + ErrCodeLoginAcctLocked: "账户已锁定,请明日再试", ErrCodeLoginAcctBanned: "登录账户已被封禁", ErrCodeLoginAcctNotEnabled: "登录账户未设置密码,请使用验证码登录", ErrCodeLoginNoChangeInAPswdReset: "新旧密码相同", diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 598c8493..42e6d081 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -999,7 +999,24 @@ func (m *Mongo) UpdateLoginByMid(ctx *gin.Context, login *dbstruct.Login, mid in return err } -// 登录表 +func (m *Mongo) ClearLoginWrongPswdTimes(ctx *gin.Context) error { + col := m.getColLogin() + + up := qmgo.M{ + "$set": qmgo.M{ + "wrong_pswd_times": int64(0), + }, + } + + filter := qmgo.M{ + "del_flag": 0, + } + + _, err := col.UpdateAll(ctx, filter, up) + return err +} + +// 登录历史表 func (m *Mongo) CreateLoginHis(ctx *gin.Context, logins []*dbstruct.Login) error { col := m.getColLoginHis() _, err := col.InsertMany(ctx, logins) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index defe7267..37a35957 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2830,10 +2830,13 @@ func (s *Service) ApiGetZoneMomentStatisticsByCreaterMid(ctx *gin.Context, req * } // 免费贴个数 - freeCount := zoneMomentCreateTimes.FreeCreateTimes - + freeCount := int64(0) // 付费贴个数 - paidCount := zoneMomentCreateTimes.PaidCreateTimes + paidCount := int64(0) + if zoneMomentCreateTimes != nil { + freeCount = zoneMomentCreateTimes.FreeCreateTimes + paidCount = zoneMomentCreateTimes.PaidCreateTimes + } // 审核未通过个数 rejectedCount, err := _DefaultZoneMoment.OpCountByMidAndStatus(ctx, req.BaseRequest.Mid, consts.ZoneMoment_Private) diff --git a/app/mix/service/cronservice.go b/app/mix/service/cronservice.go index 8af0b457..0b08d1ee 100644 --- a/app/mix/service/cronservice.go +++ b/app/mix/service/cronservice.go @@ -58,6 +58,7 @@ func (s *CronService) Init(c any) (err error) { exec.RegTask("cancel_account_at_due_time", s.CancelAccountsAtDueTime) exec.RegTask("reload_moment_recomm_list", s.ReloadMomentRecommList) exec.RegTask("clear_zone_moment_create_times", s.ClearZoneMomentCreateTimes) + exec.RegTask("clear_wrong_pswd_times", s.ClearWrongPswdTimes) exec.LogHandler(customLogHandle) //注册任务handler diff --git a/app/mix/service/logic/login.go b/app/mix/service/logic/login.go index 2c08b3ee..f72eb7c7 100644 --- a/app/mix/service/logic/login.go +++ b/app/mix/service/logic/login.go @@ -119,6 +119,16 @@ func (p *Login) OpHandleWrongPswd(ctx *gin.Context, login *dbstruct.Login) error return nil } +// 抹去密码错误次数 +func (p *Login) OpClearWrongPswdTimes(ctx *gin.Context) error { + err := p.store.ClearLoginWrongPswdTimes(ctx) + if err != nil { + logger.Error("Clear wrong password times failed : %v", err) + return err + } + return err +} + // 产生原始登录信息 func (p *Login) GenerateOriginalLogin() *dbstruct.Login { originalLogin := &dbstruct.Login{ diff --git a/app/mix/service/xxljob_tasks.go b/app/mix/service/xxljob_tasks.go index fdee6ded..de74941e 100644 --- a/app/mix/service/xxljob_tasks.go +++ b/app/mix/service/xxljob_tasks.go @@ -434,3 +434,14 @@ func (s *CronService) ClearZoneMomentCreateTimes(ctx context.Context, param *xxl logger.Info("zone_moment_create_times collection has been cleared") return "zone_moment_create_times collection has been cleared" } + +func (s *CronService) ClearWrongPswdTimes(ctx context.Context, param *xxl.RunReq) (msg string) { + logger.Info("task %v param: %v log_id: %v", param.ExecutorHandler, param.ExecutorParams, xxl.Int64ToStr(param.LogID)) + logger.Info("Clearing wrong_pswd_times...") + if err := _DefaultLogin.OpClearWrongPswdTimes(&gin.Context{}); err != nil { + logger.Error("Clear wrong_pswd_times fail: %v", err) + return fmt.Sprintf("Clear wrong_pswd_times fail: %v", err) + } + logger.Info("wrong_pswd_times has been cleared") + return "wrong_pswd_times has been cleared" +} diff --git a/vendor/github.com/xxl-job/xxl-job-executor-go/executor.go b/vendor/github.com/xxl-job/xxl-job-executor-go/executor.go index 83b59f12..f92f640f 100644 --- a/vendor/github.com/xxl-job/xxl-job-executor-go/executor.go +++ b/vendor/github.com/xxl-job/xxl-job-executor-go/executor.go @@ -288,7 +288,6 @@ func (e *executor) registry() { e.log.Error("执行器注册失败3:" + string(body)) return } - e.log.Info("执行器注册成功:" + string(body)) }() }