apply temporary lock only when mfa enabled

This commit is contained in:
Roland Osborne 2024-05-22 15:52:19 -07:00
parent 0001f6c8c9
commit df8d2806e6

View File

@ -26,14 +26,14 @@ func SetAdminAccess(w http.ResponseWriter, r *http.Request) {
curTime := time.Now().Unix() curTime := time.Now().Unix()
failedTime := getNumConfigValue(CNFMFAFailedTime, 0); failedTime := getNumConfigValue(CNFMFAFailedTime, 0);
failedCount := getNumConfigValue(CNFMFAFailedCount, 0); failedCount := getNumConfigValue(CNFMFAFailedCount, 0);
mfaEnabled := getBoolConfigValue(CNFMFAEnabled, false);
mfaConfirmed := getBoolConfigValue(CNFMFAConfirmed, false);
if mfaEnabled && mfaConfirmed {
if failedTime + APPMFAFailPeriod > curTime && failedCount > APPMFAFailCount { if failedTime + APPMFAFailPeriod > curTime && failedCount > APPMFAFailCount {
ErrResponse(w, http.StatusTooManyRequests, errors.New("temporarily locked")) ErrResponse(w, http.StatusTooManyRequests, errors.New("temporarily locked"))
return; return;
} }
mfaEnabled := getBoolConfigValue(CNFMFAEnabled, false);
mfaConfirmed := getBoolConfigValue(CNFMFAConfirmed, false);
if mfaEnabled && mfaConfirmed {
code := r.FormValue("code") code := r.FormValue("code")
if code == "" { if code == "" {
ErrResponse(w, http.StatusMethodNotAllowed, errors.New("totp code required")) ErrResponse(w, http.StatusMethodNotAllowed, errors.New("totp code required"))