Chore: Fix linting issues caught by ruleguard (#28799)

* Chore: Fix linting issues caught by ruleguard

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Improve error check

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-11-17 11:27:45 +01:00
committed by GitHub
parent 967e9b39e8
commit 2bf964c61e
6 changed files with 39 additions and 33 deletions
+6 -5
View File
@@ -6,6 +6,7 @@ import (
"hash/fnv"
"net"
"net/mail"
"path"
"reflect"
"strings"
"time"
@@ -179,12 +180,12 @@ func (auth *AuthProxy) Login(logger log.Logger, ignoreCache bool) (int64, *Error
}
if isLDAPEnabled() {
id, err := auth.LoginViaLDAP()
if err != nil {
if err == ldap.ErrInvalidCredentials {
id, e := auth.LoginViaLDAP()
if e != nil {
if e == ldap.ErrInvalidCredentials {
return 0, newError("proxy authentication required", ldap.ErrInvalidCredentials)
}
return 0, newError("failed to get the user", err)
return 0, newError("failed to get the user", e)
}
return id, nil
@@ -347,7 +348,7 @@ func (auth *AuthProxy) Remember(id int64) *Error {
func coerceProxyAddress(proxyAddr string) (*net.IPNet, error) {
proxyAddr = strings.TrimSpace(proxyAddr)
if !strings.Contains(proxyAddr, "/") {
proxyAddr = strings.Join([]string{proxyAddr, "32"}, "/")
proxyAddr = path.Join(proxyAddr, "32")
}
_, network, err := net.ParseCIDR(proxyAddr)