home: imp code
Some checks failed
build / test (macOS-latest) (push) Has been cancelled
build / test (ubuntu-latest) (push) Has been cancelled
build / test (windows-latest) (push) Has been cancelled
lint / go-lint (push) Has been cancelled
lint / eslint (push) Has been cancelled
build / build-release (push) Has been cancelled
build / notify (push) Has been cancelled
lint / notify (push) Has been cancelled

This commit is contained in:
Stanislav Chzhen
2025-08-26 15:31:31 +03:00
parent 2fdb14b579
commit 00e992b175

View File

@@ -506,21 +506,25 @@ func (mw *authMiddlewareDefault) userFromRequestBasicAuth(
return nil, fmt.Errorf("login attempt blocked for %s", left)
}
defer func() {
if err != nil {
rateLimiter.inc(remoteIP)
return
}
rateLimiter.remove(remoteIP)
}()
user, _ = mw.users.ByLogin(ctx, aghuser.Login(login))
if user == nil {
rateLimiter.inc(remoteIP)
return nil, errInvalidLogin
}
ok = user.Password.Authenticate(ctx, pass)
if !ok {
rateLimiter.inc(remoteIP)
return nil, errInvalidLogin
}
rateLimiter.remove(remoteIP)
return user, nil
}