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))
|
c.ResponseOk(object.GetMaskedApplication(application, userId))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,6 +384,13 @@ func GetMaskedApplication(application *Application, userId string) *Application
|
|||||||
application.InvitationCodes = []string{"***"}
|
application.InvitationCodes = []string{"***"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if application.FailedSigninLimit == 0 {
|
||||||
|
application.FailedSigninLimit = DefaultFailedSigninLimit
|
||||||
|
}
|
||||||
|
if application.FailedSigninfrozenTime == 0 {
|
||||||
|
application.FailedSigninfrozenTime = DefaultFailedSigninfrozenTime
|
||||||
|
}
|
||||||
|
|
||||||
return application
|
return application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultFailedSigninLimit = 5
|
DefaultFailedSigninLimit = 5
|
||||||
// DefaultFailedSigninfrozenTime The unit of frozen time is minutes
|
|
||||||
DefaultFailedSigninfrozenTime = 15
|
DefaultFailedSigninfrozenTime = 15
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -509,12 +508,11 @@ func CheckToEnableCaptcha(application *Application, organization, username strin
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var failedSigninLimit int
|
failedSigninLimit := application.FailedSigninLimit
|
||||||
if application.FailedSigninLimit == 0 {
|
if failedSigninLimit == 0 {
|
||||||
failedSigninLimit = 5
|
failedSigninLimit = DefaultFailedSigninLimit
|
||||||
} else {
|
|
||||||
failedSigninLimit = application.FailedSigninLimit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return user != nil && user.SigninWrongTimes >= failedSigninLimit, nil
|
return user != nil && user.SigninWrongTimes >= failedSigninLimit, nil
|
||||||
}
|
}
|
||||||
return providerItem.Rule == "Always", nil
|
return providerItem.Rule == "Always", nil
|
||||||
|
@ -52,13 +52,13 @@ func GetFailedSigninConfigByUser(user *User) (int, int, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
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 {
|
if failedSigninLimit == 0 {
|
||||||
failedSigninLimit = DefaultFailedSigninLimit
|
failedSigninLimit = DefaultFailedSigninLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
failedSigninfrozenTime := application.FailedSigninfrozenTime
|
||||||
if failedSigninfrozenTime == 0 {
|
if failedSigninfrozenTime == 0 {
|
||||||
failedSigninfrozenTime = DefaultFailedSigninfrozenTime
|
failedSigninfrozenTime = DefaultFailedSigninfrozenTime
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user