by Robin at 20240425

This commit is contained in:
Leufolium 2024-04-25 10:01:34 +08:00
parent 5d7220246e
commit 3fef23d3c3
7 changed files with 47 additions and 6 deletions

View File

@ -32,7 +32,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeLoginWrongPswd: "登录密码错误",
ErrCodeLoginWrongVeriCode: "验证码错误",
ErrCodeLoginVeriCodeExpired: "验证码已过期",
ErrCodeLoginAcctLocked: "登录账户尝试爆破登录,锁定",
ErrCodeLoginAcctLocked: "账户已锁定,请明日再试",
ErrCodeLoginAcctBanned: "登录账户已被封禁",
ErrCodeLoginAcctNotEnabled: "登录账户未设置密码,请使用验证码登录",
ErrCodeLoginNoChangeInAPswdReset: "新旧密码相同",

View File

@ -997,7 +997,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)

View File

@ -2823,10 +2823,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)

View File

@ -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

View File

@ -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{

View File

@ -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"
}

View File

@ -288,7 +288,6 @@ func (e *executor) registry() {
e.log.Error("执行器注册失败3:" + string(body))
return
}
e.log.Info("执行器注册成功:" + string(body))
}()
}