Explorar el Código

review fix

tags/v2.4.0-rc1
Shivaram Lingamneni hace 3 años
padre
commit
7fd5bc8d81
Se han modificado 2 ficheros con 9 adiciones y 11 borrados
  1. 8
    10
      irc/handlers.go
  2. 1
    1
      irc/nickserv.go

+ 8
- 10
irc/handlers.go Ver fichero

@@ -60,19 +60,18 @@ func parseCallback(spec string, config *Config) (callbackNamespace string, callb
60 60
 	return
61 61
 }
62 62
 
63
-func registrationErrorToMessageAndCode(err error) (message, code string) {
64
-	// default responses: let's be risk-averse about displaying internal errors
65
-	// to the clients, especially for something as sensitive as accounts
66
-	code = "REG_UNSPECIFIED_ERROR"
67
-	message = `Could not register`
63
+func registrationErrorToMessage(err error) (message string) {
68 64
 	switch err {
69
-	case errAccountBadPassphrase:
70
-		code = "REG_INVALID_CREDENTIAL"
71
-		message = err.Error()
72
-	case errAccountAlreadyRegistered, errAccountAlreadyVerified, errAccountAlreadyUnregistered, errAccountAlreadyLoggedIn, errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled:
65
+	case errAccountAlreadyRegistered, errAccountAlreadyVerified, errAccountAlreadyUnregistered, errAccountAlreadyLoggedIn, errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled, errAccountBadPassphrase:
73 66
 		message = err.Error()
74 67
 	case errLimitExceeded:
75 68
 		message = `There have been too many registration attempts recently; try again later`
69
+	case errCallbackFailed:
70
+		message = `Could not dispatch verification email`
71
+	default:
72
+		// default response: let's be risk-averse about displaying internal errors
73
+		// to the clients, especially for something as sensitive as accounts
74
+		message = `Could not register`
76 75
 	}
77 76
 	return
78 77
 }
@@ -2460,7 +2459,6 @@ func registerHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *
2460 2459
 	case errAccountBadPassphrase:
2461 2460
 		rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_PASSWORD", client.t("Password was invalid"))
2462 2461
 	case errCallbackFailed:
2463
-		// TODO detect this in NS REGISTER as well
2464 2462
 		rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", client.t("Could not dispatch verification e-mail"))
2465 2463
 	default:
2466 2464
 		rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", client.t("Could not register"))

+ 1
- 1
irc/nickserv.go Ver fichero

@@ -873,7 +873,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
873 873
 		}
874 874
 	} else {
875 875
 		// details could not be stored and relevant numerics have been dispatched, abort
876
-		message, _ := registrationErrorToMessageAndCode(err)
876
+		message := registrationErrorToMessage(err)
877 877
 		nsNotice(rb, client.t(message))
878 878
 	}
879 879
 }

Loading…
Cancelar
Guardar