|
@@ -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"))
|