From 47ac0543b9ed2d4afb8814a19e2f4dc3c30030e1 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 29 Sep 2020 20:41:55 +0200 Subject: [feat] improve error handling during login --- pkg/backend/api.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg/backend/api.go') diff --git a/pkg/backend/api.go b/pkg/backend/api.go index 1d44f8a..4390fef 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -18,10 +18,12 @@ import ( func Login(username, password string) { success, err := ctx.bm.DoLogin(username, password) if err != nil { - log.Printf("Error on login: %v", err) - if err.Error() == "Cannot get token: Error 502" { + if err.Error() == "TokenErrTimeout" { + ctx.Errors = "bad_auth_timeout" + } else if err.Error() == "TokenErrBadStatus 502" { ctx.Errors = "bad_auth_502" } else { + log.Println("ERROR: bad login", err) ctx.Errors = "bad_auth" } } else if success { @@ -29,7 +31,6 @@ func Login(username, password string) { ctx.LoginOk = true ctx.LoginDialog = false } else { - // TODO: display login again with an err log.Printf("Failed to login as %s", username) ctx.LoginDialog = true ctx.Errors = "bad_auth" -- cgit v1.2.3