diff --git a/gencapdefs.py b/gencapdefs.py index 985f2ac3..48e734f2 100644 --- a/gencapdefs.py +++ b/gencapdefs.py @@ -172,10 +172,10 @@ CAPDEFS = [ standard="proposed IRCv3", ), CapDef( - identifier="Register", - name="draft/register", - url="https://gist.github.com/edk0/bf3b50fc219fd1bed1aa15d98bfb6495", - standard="proposed IRCv3", + identifier="AccountRegistration", + name="draft/account-registration", + url="https://github.com/ircv3/ircv3-specifications/pull/435", + standard="draft IRCv3", ), ] diff --git a/irc/caps/defs.go b/irc/caps/defs.go index 4bfd3e29..aa988812 100644 --- a/irc/caps/defs.go +++ b/irc/caps/defs.go @@ -37,6 +37,10 @@ const ( // https://ircv3.net/specs/extensions/chghost-3.2.html ChgHost Capability = iota + // AccountRegistration is the draft IRCv3 capability named "draft/account-registration": + // https://github.com/ircv3/ircv3-specifications/pull/435 + AccountRegistration Capability = iota + // ChannelRename is the draft IRCv3 capability named "draft/channel-rename": // https://ircv3.net/specs/extensions/channel-rename ChannelRename Capability = iota @@ -57,10 +61,6 @@ const ( // https://github.com/ircv3/ircv3-specifications/pull/398 Multiline Capability = iota - // Register is the proposed IRCv3 capability named "draft/register": - // https://gist.github.com/edk0/bf3b50fc219fd1bed1aa15d98bfb6495 - Register Capability = iota - // Relaymsg is the proposed IRCv3 capability named "draft/relaymsg": // https://github.com/ircv3/ircv3-specifications/pull/417 Relaymsg Capability = iota @@ -131,12 +131,12 @@ var ( "batch", "cap-notify", "chghost", + "draft/account-registration", "draft/channel-rename", "draft/chathistory", "draft/event-playback", "draft/languages", "draft/multiline", - "draft/register", "draft/relaymsg", "echo-message", "extended-join", diff --git a/irc/commands.go b/irc/commands.go index 04865ea9..19ea99f5 100644 --- a/irc/commands.go +++ b/irc/commands.go @@ -246,7 +246,7 @@ func init() { }, "REGISTER": { handler: registerHandler, - minParams: 2, + minParams: 3, usablePreReg: true, }, "RENAME": { diff --git a/irc/config.go b/irc/config.go index 52cc0bf9..72898abb 100644 --- a/irc/config.go +++ b/irc/config.go @@ -1385,7 +1385,7 @@ func LoadConfig(filename string) (config *Config, err error) { } if !config.Accounts.Registration.Enabled { - config.Server.supportedCaps.Disable(caps.Register) + config.Server.supportedCaps.Disable(caps.AccountRegistration) } else { var registerValues []string if config.Accounts.Registration.AllowBeforeConnect { @@ -1398,7 +1398,7 @@ func LoadConfig(filename string) (config *Config, err error) { registerValues = append(registerValues, "account-required") } if len(registerValues) != 0 { - config.Server.capValues[caps.Register] = strings.Join(registerValues, ",") + config.Server.capValues[caps.AccountRegistration] = strings.Join(registerValues, ",") } } diff --git a/irc/handlers.go b/irc/handlers.go index bd15175d..64e2f25c 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2486,12 +2486,21 @@ func quitHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons return true } -// REGISTER < email | * > +// REGISTER < account | * > < email | * > func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) { accountName := client.Nick() if accountName == "*" { accountName = client.preregNick } + + switch msg.Params[0] { + case "*", accountName: + // ok + default: + rb.Add(nil, server.name, "FAIL", "REGISTER", "ACCOUNTNAME_MUST_BE_NICK", utils.SafeErrorParam(msg.Params[0]), client.t("You may only register your nickname as your account name")) + return + } + // check that accountName is valid as a non-final parameter; // this is necessary for us to be valid and it will prevent us from emitting invalid error lines nickErrorParam := utils.SafeErrorParam(accountName) @@ -2514,13 +2523,13 @@ func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res return } - callbackNamespace, callbackValue, err := parseCallback(msg.Params[0], config) + callbackNamespace, callbackValue, err := parseCallback(msg.Params[1], config) if err != nil { rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_EMAIL", accountName, client.t("A valid e-mail address is required")) return } - err = server.accounts.Register(client, accountName, callbackNamespace, callbackValue, msg.Params[1], rb.session.certfp) + err = server.accounts.Register(client, accountName, callbackNamespace, callbackValue, msg.Params[2], rb.session.certfp) switch err { case nil: if callbackNamespace == "*" { diff --git a/irctest b/irctest index 0b17fc84..a29b7c56 160000 --- a/irctest +++ b/irctest @@ -1 +1 @@ -Subproject commit 0b17fc84606ce8e1d52b04ad569b99f8d12e0b04 +Subproject commit a29b7c5631bfce49276d62578bffa2b19e56ab10