fix: checkorigin when debug enabled & update fronted dist

This commit is contained in:
naiba
2024-12-01 00:00:01 +08:00
parent 166f25508c
commit cb06a303b7
3 changed files with 45 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import (
jwt "github.com/appleboy/gin-jwt/v2"
"github.com/gin-gonic/gin"
"golang.org/x/crypto/bcrypt"
"gorm.io/gorm"
"github.com/nezhahq/nezha/cmd/dashboard/controller/waf"
"github.com/nezhahq/nezha/model"
@@ -88,7 +89,9 @@ func authenticator() func(c *gin.Context) (interface{}, error) {
var user model.User
if err := singleton.DB.Select("id", "password").Where("username = ?", loginVals.Username).First(&user).Error; err != nil {
model.BlockIP(singleton.DB, c.GetString(model.CtxKeyRealIPStr), model.WAFBlockReasonTypeLoginFail)
if err == gorm.ErrRecordNotFound {
model.BlockIP(singleton.DB, c.GetString(model.CtxKeyRealIPStr), model.WAFBlockReasonTypeLoginFail)
}
return nil, jwt.ErrFailedAuthentication
}