|
@@ -63,14 +63,16 @@ func parseCallback(spec string, config *Config) (callbackNamespace string, callb
|
63
|
63
|
return
|
64
|
64
|
}
|
65
|
65
|
|
66
|
|
-func registrationErrorToMessage(err error) (message string) {
|
|
66
|
+func registrationErrorToMessage(config *Config, client *Client, err error) (message string) {
|
|
67
|
+ if emailError := registrationCallbackErrorText(config, client, err); emailError != "" {
|
|
68
|
+ return emailError
|
|
69
|
+ }
|
|
70
|
+
|
67
|
71
|
switch err {
|
68
|
72
|
case errAccountAlreadyRegistered, errAccountAlreadyVerified, errAccountAlreadyUnregistered, errAccountAlreadyLoggedIn, errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled, errAccountBadPassphrase:
|
69
|
73
|
message = err.Error()
|
70
|
74
|
case errLimitExceeded:
|
71
|
75
|
message = `There have been too many registration attempts recently; try again later`
|
72
|
|
- case errCallbackFailed:
|
73
|
|
- message = `Could not dispatch verification email`
|
74
|
76
|
default:
|
75
|
77
|
// default response: let's be risk-averse about displaying internal errors
|
76
|
78
|
// to the clients, especially for something as sensitive as accounts
|
|
@@ -2548,10 +2550,12 @@ func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
|
2548
|
2550
|
rb.Add(nil, server.name, "FAIL", "REGISTER", "USERNAME_EXISTS", accountName, client.t("Username is already registered or otherwise unavailable"))
|
2549
|
2551
|
case errAccountBadPassphrase:
|
2550
|
2552
|
rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_PASSWORD", accountName, client.t("Password was invalid"))
|
2551
|
|
- case errCallbackFailed:
|
2552
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", accountName, client.t("Could not dispatch verification e-mail"))
|
2553
|
2553
|
default:
|
2554
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", accountName, client.t("Could not register"))
|
|
2554
|
+ if emailError := registrationCallbackErrorText(config, client, err); emailError != "" {
|
|
2555
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", accountName, emailError)
|
|
2556
|
+ } else {
|
|
2557
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", accountName, client.t("Could not register"))
|
|
2558
|
+ }
|
2555
|
2559
|
}
|
2556
|
2560
|
return
|
2557
|
2561
|
}
|