mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
fix: oauth2 redirect url not consistent (#930)
* fix: oauth2 redirect url not consistent * only use one redirect uri * feat: allow to disable password authentication * generate translation template * update error * redirect * query
This commit is contained in:
@@ -89,6 +89,7 @@ func authenticator() func(c *gin.Context) (interface{}, error) {
|
||||
|
||||
var user model.User
|
||||
realip := c.GetString(model.CtxKeyRealIPStr)
|
||||
|
||||
if err := singleton.DB.Select("id", "password").Where("username = ?", loginVals.Username).First(&user).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
model.BlockIP(singleton.DB, realip, model.WAFBlockReasonTypeLoginFail, model.BlockIDUnknownUser)
|
||||
@@ -96,6 +97,11 @@ func authenticator() func(c *gin.Context) (interface{}, error) {
|
||||
return nil, jwt.ErrFailedAuthentication
|
||||
}
|
||||
|
||||
if user.RejectPassword {
|
||||
model.BlockIP(singleton.DB, realip, model.WAFBlockReasonTypeLoginFail, int64(user.ID))
|
||||
return nil, jwt.ErrFailedAuthentication
|
||||
}
|
||||
|
||||
if err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(loginVals.Password)); err != nil {
|
||||
model.BlockIP(singleton.DB, realip, model.WAFBlockReasonTypeLoginFail, int64(user.ID))
|
||||
return nil, jwt.ErrFailedAuthentication
|
||||
|
||||
Reference in New Issue
Block a user