|
@@ -2443,32 +2443,34 @@ func quitHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *Resp
|
2443
|
2443
|
|
2444
|
2444
|
// REGISTER < email | * > <password>
|
2445
|
2445
|
func registerHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *ResponseBuffer) (exiting bool) {
|
|
2446
|
+ accountName := client.Nick()
|
|
2447
|
+ if accountName == "*" {
|
|
2448
|
+ accountName = client.preregNick
|
|
2449
|
+ }
|
|
2450
|
+ // check that accountName is valid as a non-final parameter;
|
|
2451
|
+ // this is necessary for us to be valid and it will prevent us from emitting invalid error lines
|
|
2452
|
+ if accountName == "*" || accountName != utils.SafeErrorParam(accountName) {
|
|
2453
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_USERNAME", accountName, client.t("Username invalid or not given"))
|
|
2454
|
+ return
|
|
2455
|
+ }
|
|
2456
|
+
|
2446
|
2457
|
config := server.Config()
|
2447
|
2458
|
if !config.Accounts.Registration.Enabled {
|
2448
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "DISALLOWED", client.t("Account registration is disabled"))
|
|
2459
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "DISALLOWED", accountName, client.t("Account registration is disabled"))
|
2449
|
2460
|
return
|
2450
|
2461
|
}
|
2451
|
2462
|
if !client.registered && !config.Accounts.Registration.AllowBeforeConnect {
|
2452
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "DISALLOWED", client.t("You must complete the connection before registering your account"))
|
|
2463
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "COMPLETE_CONNECTION_REQUIRED", accountName, client.t("You must complete the connection before registering your account"))
|
2453
|
2464
|
return
|
2454
|
2465
|
}
|
2455
|
2466
|
if client.registerCmdSent || client.Account() != "" {
|
2456
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "ALREADY_REGISTERED", client.t("You have already registered or attempted to register"))
|
2457
|
|
- return
|
2458
|
|
- }
|
2459
|
|
-
|
2460
|
|
- accountName := client.Nick()
|
2461
|
|
- if accountName == "*" {
|
2462
|
|
- accountName = client.preregNick
|
2463
|
|
- }
|
2464
|
|
- if accountName == "" || accountName == "*" {
|
2465
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_USERNAME", client.t("Username invalid or not given"))
|
|
2467
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "ALREADY_REGISTERED", accountName, client.t("You have already registered or attempted to register"))
|
2466
|
2468
|
return
|
2467
|
2469
|
}
|
2468
|
2470
|
|
2469
|
2471
|
callbackNamespace, callbackValue, err := parseCallback(msg.Params[0], config)
|
2470
|
2472
|
if err != nil {
|
2471
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_EMAIL", client.t("A valid e-mail address is required"))
|
|
2473
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_EMAIL", accountName, client.t("A valid e-mail address is required"))
|
2472
|
2474
|
return
|
2473
|
2475
|
}
|
2474
|
2476
|
|
|
@@ -2497,13 +2499,13 @@ func registerHandler(server *Server, client *Client, msg ircmsg.IRCMessage, rb *
|
2497
|
2499
|
client.registerCmdSent = true
|
2498
|
2500
|
}
|
2499
|
2501
|
case errAccountAlreadyRegistered, errAccountAlreadyUnregistered, errAccountMustHoldNick:
|
2500
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "USERNAME_EXISTS", client.t("Username is already registered or otherwise unavailable"))
|
|
2502
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "USERNAME_EXISTS", accountName, client.t("Username is already registered or otherwise unavailable"))
|
2501
|
2503
|
case errAccountBadPassphrase:
|
2502
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_PASSWORD", client.t("Password was invalid"))
|
|
2504
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_PASSWORD", accountName, client.t("Password was invalid"))
|
2503
|
2505
|
case errCallbackFailed:
|
2504
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", client.t("Could not dispatch verification e-mail"))
|
|
2506
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "UNACCEPTABLE_EMAIL", accountName, client.t("Could not dispatch verification e-mail"))
|
2505
|
2507
|
default:
|
2506
|
|
- rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", client.t("Could not register"))
|
|
2508
|
+ rb.Add(nil, server.name, "FAIL", "REGISTER", "UNKNOWN_ERROR", accountName, client.t("Could not register"))
|
2507
|
2509
|
}
|
2508
|
2510
|
return
|
2509
|
2511
|
}
|