From 6720bfb24312a558a27453ce104beeb04c53ec68 Mon Sep 17 00:00:00 2001 From: Josh Hawn Date: Thu, 5 Dec 2013 15:10:44 -0800 Subject: [PATCH] Adjusted handling of inactive user login The return status for inactive users was being checked too early in the process, so I moved it from just after the handling of POST /v1/users/ to after getting the response from GET /v1/users/ --- auth/auth.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 85844a5472..e88fb908f9 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -192,13 +192,6 @@ func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, e } else { status = "Account created. Please see the documentation of the registry " + serverAddress + " for instructions how to activate it." } - } else if reqStatusCode == 403 { - if loginAgainstOfficialIndex { - return "", fmt.Errorf("Login: Your account hasn't been activated. " + - "Please check your e-mail for a confirmation link.") - } - return "", fmt.Errorf("Login: Your account hasn't been activated. " + - "Please see the documentation of the registry " + serverAddress + " for instructions how to activate it.") } else if reqStatusCode == 400 { if string(reqBody) == "\"Username or email already exists\"" { req, err := factory.NewRequest("GET", serverAddress+"users/", nil) @@ -216,9 +209,13 @@ func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, e status = "Login Succeeded" } else if resp.StatusCode == 401 { return "", fmt.Errorf("Wrong login/password, please try again") + } else if resp.StatusCode == 403 { + if loginAgainstOfficialIndex { + return "", fmt.Errorf("Login: Account is not Active. Please check your e-mail for a confirmation link.") + } + return "", fmt.Errorf("Login: Account is not Active. Please see the documentation of the registry %s for instructions how to activate it.", serverAddress) } else { - return "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body, - resp.StatusCode, resp.Header) + return "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body, resp.StatusCode, resp.Header) } } else { return "", fmt.Errorf("Registration: %s", reqBody) @@ -236,7 +233,7 @@ func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, e body, err := ioutil.ReadAll(resp.Body) if err != nil { return "", err - } + } if resp.StatusCode == 200 { status = "Login Succeeded" } else if resp.StatusCode == 401 {