feat: add message push function call

This commit is contained in:
engigu
2026-03-04 21:45:43 +08:00
parent d4663cb492
commit 81b8d2a93d
53 changed files with 4161 additions and 33 deletions
+10
View File
@@ -1,6 +1,7 @@
package controllers
import (
"strconv"
"sync"
"time"
@@ -54,6 +55,10 @@ func (ac *AuthController) Login(c *gin.Context) {
attempt := val.(*loginAttempt)
if attempt.Count >= 5 && time.Since(attempt.LastAttempt) < time.Minute {
ac.loginLogService.Create(req.Username, ip, userAgent, "failed", "尝试次数过多,请一分钟后再试")
go services.NewNotificationService().TriggerEvent(constant.BindingTypeSystem, constant.EventBruteForceLogin, "", map[string]interface{}{
"ip": ip,
"username": req.Username,
})
utils.TooManyRequests(c, "尝试次数过多,请一分钟后再试")
return
}
@@ -102,6 +107,11 @@ func (ac *AuthController) Login(c *gin.Context) {
// 记录登录成功日志
ac.loginLogService.Create(req.Username, ip, userAgent, "success", "登录成功")
go services.NewNotificationService().TriggerEvent(constant.BindingTypeSystem, constant.EventUserLogin, "", map[string]interface{}{
"ip": ip,
"username": req.Username,
})
utils.Success(c, gin.H{
"user": user.Username,
})