mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Repair broken error handlng
This commit is contained in:
parent
32b0c8bdd7
commit
da551a0bb4
@ -122,14 +122,14 @@ func Init() (*Authentication, error) {
|
|||||||
|
|
||||||
jwtSessionAuth := &JWTSessionAuthenticator{}
|
jwtSessionAuth := &JWTSessionAuthenticator{}
|
||||||
if err := jwtSessionAuth.Init(); err != nil {
|
if err := jwtSessionAuth.Init(); err != nil {
|
||||||
log.Info("jwtSessionAuth init failed: No JWT login support!")
|
log.Info("jwtSessionAuth init failed: No JWT login support!")
|
||||||
} else {
|
} else {
|
||||||
auth.authenticators = append(auth.authenticators, jwtSessionAuth)
|
auth.authenticators = append(auth.authenticators, jwtSessionAuth)
|
||||||
}
|
}
|
||||||
|
|
||||||
jwtCookieSessionAuth := &JWTCookieSessionAuthenticator{}
|
jwtCookieSessionAuth := &JWTCookieSessionAuthenticator{}
|
||||||
if err := jwtCookieSessionAuth.Init(); err != nil {
|
if err := jwtCookieSessionAuth.Init(); err != nil {
|
||||||
log.Info("jwtCookieSessionAuth init failed: No JWT cookie login support!")
|
log.Info("jwtCookieSessionAuth init failed: No JWT cookie login support!")
|
||||||
} else {
|
} else {
|
||||||
auth.authenticators = append(auth.authenticators, jwtCookieSessionAuth)
|
auth.authenticators = append(auth.authenticators, jwtCookieSessionAuth)
|
||||||
}
|
}
|
||||||
@ -152,11 +152,11 @@ func (auth *Authentication) Login(
|
|||||||
onfailure func(rw http.ResponseWriter, r *http.Request, loginErr error)) http.Handler {
|
onfailure func(rw http.ResponseWriter, r *http.Request, loginErr error)) http.Handler {
|
||||||
|
|
||||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||||
err := errors.New("no authenticator applied")
|
|
||||||
username := r.FormValue("username")
|
username := r.FormValue("username")
|
||||||
var dbUser *schema.User
|
var dbUser *schema.User
|
||||||
|
|
||||||
if username != "" {
|
if username != "" {
|
||||||
|
var err error
|
||||||
dbUser, err = repository.GetUserRepository().GetUser(username)
|
dbUser, err = repository.GetUserRepository().GetUser(username)
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
log.Errorf("Error while loading user '%v'", username)
|
log.Errorf("Error while loading user '%v'", username)
|
||||||
@ -170,7 +170,7 @@ func (auth *Authentication) Login(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err = authenticator.Login(user, rw, r)
|
user, err := authenticator.Login(user, rw, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("user login failed: %s", err.Error())
|
log.Warnf("user login failed: %s", err.Error())
|
||||||
onfailure(rw, r, err)
|
onfailure(rw, r, err)
|
||||||
@ -203,7 +203,7 @@ func (auth *Authentication) Login(
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("login failed: no authenticator applied")
|
log.Debugf("login failed: no authenticator applied")
|
||||||
onfailure(rw, r, err)
|
onfailure(rw, r, errors.New("no authenticator applied"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user