From a551b375fa6bed975e8df88bf5d024df957a7684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Fri, 28 Sep 2018 16:55:14 +0200 Subject: Idiomatic error handling for app/{job,license,login}.go (#9474) --- app/login.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'app/login.go') diff --git a/app/login.go b/app/login.go index 5099a3e7a..01cdde386 100644 --- a/app/login.go +++ b/app/login.go @@ -96,17 +96,16 @@ func (a *App) GetUserForLogin(id, loginId string) (*model.User, *model.AppError) // If we are given a userID then fail if we can't find a user with that ID if len(id) != 0 { - if user, err := a.GetUser(id); err != nil { + user, err := a.GetUser(id) + if err != nil { if err.Id != store.MISSING_ACCOUNT_ERROR { err.StatusCode = http.StatusInternalServerError return nil, err - } else { - err.StatusCode = http.StatusBadRequest - return nil, err } - } else { - return user, nil + err.StatusCode = http.StatusBadRequest + return nil, err } + return user, nil } // Try to get the user by username/email @@ -200,7 +199,6 @@ func (a *App) DoLogin(w http.ResponseWriter, r *http.Request, user *model.User, func GetProtocol(r *http.Request) string { if r.Header.Get(model.HEADER_FORWARDED_PROTO) == "https" || r.TLS != nil { return "https" - } else { - return "http" } + return "http" } -- cgit v1.2.3-1-g7c22