mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
Refactor application.FailedSigninLimit code
This commit is contained in:
@ -110,14 +110,6 @@ func (c *ApiController) GetApplication() {
|
||||
}
|
||||
}
|
||||
|
||||
// 0 as an initialization value, corresponding to the default configuration parameters
|
||||
if application.FailedSigninLimit == 0 {
|
||||
application.FailedSigninLimit = object.DefaultFailedSigninLimit
|
||||
}
|
||||
if application.FailedSigninfrozenTime == 0 {
|
||||
application.FailedSigninfrozenTime = object.DefaultFailedSigninfrozenTime
|
||||
}
|
||||
|
||||
c.ResponseOk(object.GetMaskedApplication(application, userId))
|
||||
}
|
||||
|
||||
|
@ -384,6 +384,13 @@ func GetMaskedApplication(application *Application, userId string) *Application
|
||||
application.InvitationCodes = []string{"***"}
|
||||
}
|
||||
|
||||
if application.FailedSigninLimit == 0 {
|
||||
application.FailedSigninLimit = DefaultFailedSigninLimit
|
||||
}
|
||||
if application.FailedSigninfrozenTime == 0 {
|
||||
application.FailedSigninfrozenTime = DefaultFailedSigninfrozenTime
|
||||
}
|
||||
|
||||
return application
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
|
||||
const (
|
||||
DefaultFailedSigninLimit = 5
|
||||
// DefaultFailedSigninfrozenTime The unit of frozen time is minutes
|
||||
DefaultFailedSigninfrozenTime = 15
|
||||
)
|
||||
|
||||
@ -509,12 +508,11 @@ func CheckToEnableCaptcha(application *Application, organization, username strin
|
||||
return false, err
|
||||
}
|
||||
|
||||
var failedSigninLimit int
|
||||
if application.FailedSigninLimit == 0 {
|
||||
failedSigninLimit = 5
|
||||
} else {
|
||||
failedSigninLimit = application.FailedSigninLimit
|
||||
failedSigninLimit := application.FailedSigninLimit
|
||||
if failedSigninLimit == 0 {
|
||||
failedSigninLimit = DefaultFailedSigninLimit
|
||||
}
|
||||
|
||||
return user != nil && user.SigninWrongTimes >= failedSigninLimit, nil
|
||||
}
|
||||
return providerItem.Rule == "Always", nil
|
||||
|
@ -52,13 +52,13 @@ func GetFailedSigninConfigByUser(user *User) (int, int, error) {
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
failedSigninLimit := application.FailedSigninLimit
|
||||
failedSigninfrozenTime := application.FailedSigninfrozenTime
|
||||
|
||||
// 0 as an initialization value, corresponding to the default configuration parameters
|
||||
failedSigninLimit := application.FailedSigninLimit
|
||||
if failedSigninLimit == 0 {
|
||||
failedSigninLimit = DefaultFailedSigninLimit
|
||||
}
|
||||
|
||||
failedSigninfrozenTime := application.FailedSigninfrozenTime
|
||||
if failedSigninfrozenTime == 0 {
|
||||
failedSigninfrozenTime = DefaultFailedSigninfrozenTime
|
||||
}
|
||||
|
Reference in New Issue
Block a user