|
@@ -40,18 +40,17 @@ func accHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
|
40
|
40
|
|
41
|
41
|
rb.Add(nil, server.name, "ACC", "LS", "SUBCOMMANDS", "LS REGISTER VERIFY")
|
42
|
42
|
|
43
|
|
- var enabledCallbacks []string
|
44
|
|
- for _, name := range config.Registration.EnabledCallbacks {
|
45
|
|
- enabledCallbacks = append(enabledCallbacks, name)
|
46
|
|
- }
|
47
|
|
- sort.Strings(enabledCallbacks)
|
48
|
|
- rb.Add(nil, server.name, "ACC", "LS", "CALLBACKS", strings.Join(enabledCallbacks, " "))
|
|
43
|
+ // this list is sorted by the config loader, yay
|
|
44
|
+ rb.Add(nil, server.name, "ACC", "LS", "CALLBACKS", strings.Join(config.Registration.EnabledCallbacks, " "))
|
49
|
45
|
|
50
|
46
|
rb.Add(nil, server.name, "ACC", "LS", "CREDTYPES", "passphrase certfp")
|
51
|
47
|
|
|
48
|
+ flags := []string{"nospaces"}
|
52
|
49
|
if config.NickReservation.Enabled {
|
53
|
|
- rb.Add(nil, server.name, "ACC", "LS", "FLAGS", "regnick")
|
|
50
|
+ flags = append(flags, "regnick")
|
54
|
51
|
}
|
|
52
|
+ sort.Strings(flags)
|
|
53
|
+ rb.Add(nil, server.name, "ACC", "LS", "FLAGS", strings.Join(flags, " "))
|
55
|
54
|
return false
|
56
|
55
|
}
|
57
|
56
|
|
|
@@ -113,7 +112,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
113
|
112
|
return false
|
114
|
113
|
}
|
115
|
114
|
|
116
|
|
- account := strings.TrimSpace(msg.Params[1])
|
|
115
|
+ account := msg.Params[1]
|
117
|
116
|
|
118
|
117
|
// check for account name of *
|
119
|
118
|
if account == "*" {
|
|
@@ -166,7 +165,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
166
|
165
|
}
|
167
|
166
|
}
|
168
|
167
|
if credentialType == "certfp" && client.certfp == "" {
|
169
|
|
- rb.Add(nil, server.name, "FAIL", "ACC", "REG_INVALID_CRED_TYPE", account, credentialType, client.t("You are not using a TLS certificate"))
|
|
168
|
+ rb.Add(nil, server.name, "FAIL", "ACC", "REG_INVALID_CREDENTIAL", account, client.t("You must connect with a TLS client certificate to use certfp"))
|
170
|
169
|
return false
|
171
|
170
|
}
|
172
|
171
|
|
|
@@ -190,8 +189,8 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
190
|
189
|
|
191
|
190
|
err = server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, certfp)
|
192
|
191
|
if err != nil {
|
193
|
|
- msg := registrationErrorToMessageAndCode(err)
|
194
|
|
- rb.Add(nil, server.name, "FAIL", "ACC", "REG_UNSPECIFIED_ERROR", account, client.t(msg))
|
|
192
|
+ msg, code := registrationErrorToMessageAndCode(err)
|
|
193
|
+ rb.Add(nil, server.name, "FAIL", "ACC", code, account, client.t(msg))
|
195
|
194
|
return false
|
196
|
195
|
}
|
197
|
196
|
|
|
@@ -211,11 +210,15 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
211
|
210
|
return false
|
212
|
211
|
}
|
213
|
212
|
|
214
|
|
-func registrationErrorToMessageAndCode(err error) (message string) {
|
|
213
|
+func registrationErrorToMessageAndCode(err error) (message, code string) {
|
215
|
214
|
// default responses: let's be risk-averse about displaying internal errors
|
216
|
215
|
// to the clients, especially for something as sensitive as accounts
|
|
216
|
+ code = "REG_UNSPECIFIED_ERROR"
|
217
|
217
|
message = `Could not register`
|
218
|
218
|
switch err {
|
|
219
|
+ case errAccountBadPassphrase:
|
|
220
|
+ code = "REG_INVALID_CREDENTIAL"
|
|
221
|
+ message = err.Error()
|
219
|
222
|
case errAccountAlreadyRegistered, errAccountAlreadyVerified:
|
220
|
223
|
message = err.Error()
|
221
|
224
|
case errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled:
|