diff --git a/irc/accountreg.go b/irc/accountreg.go index f17100a3..4313f1a9 100644 --- a/irc/accountreg.go +++ b/irc/accountreg.go @@ -55,23 +55,23 @@ func NewAccountRegistration(config AccountRegistrationConfig) (accountReg Accoun return accountReg } -// regHandler parses the REG command. -func regHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { +// accHandler parses the ACC command. +func accHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { subcommand := strings.ToLower(msg.Params[0]) - if subcommand == "create" { - return regCreateHandler(server, client, msg) + if subcommand == "register" { + return accRegisterHandler(server, client, msg) } else if subcommand == "verify" { - client.Notice("Parsing VERIFY") + client.Notice("VERIFY is not yet implemented") } else { - client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REG", msg.Params[0], "Unknown subcommand") + client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", msg.Params[0], "Unknown subcommand") } return false } -// removeFailedRegCreateData removes the data created by REG CREATE if the account creation fails early. -func removeFailedRegCreateData(store *buntdb.DB, account string) { +// removeFailedAccRegisterData removes the data created by ACC REGISTER if the account creation fails early. +func removeFailedAccRegisterData(store *buntdb.DB, account string) { // error is ignored here, we can't do much about it anyways store.Update(func(tx *buntdb.Tx) error { tx.Delete(fmt.Sprintf(keyAccountExists, account)) @@ -82,8 +82,8 @@ func removeFailedRegCreateData(store *buntdb.DB, account string) { }) } -// regCreateHandler parses the REG CREATE command. -func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { +// accRegisterHandler parses the ACC REGISTER command. +func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { // make sure reg is enabled if !server.accountRegistration.Enabled { client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", "Account registration is disabled") @@ -122,7 +122,7 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo // account could not be created and relevant numerics have been dispatched, abort if err != nil { if err != errAccountCreation { - client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REG", "CREATE", "Could not register") + client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", "Could not register") log.Println("Could not save registration initial data:", err.Error()) } return false @@ -153,7 +153,7 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo if !callbackValid { client.Send(nil, server.name, ERR_REG_INVALID_CALLBACK, client.nick, account, callbackNamespace, "Callback namespace is not supported") - removeFailedRegCreateData(server.store, casefoldedAccount) + removeFailedAccRegisterData(server.store, casefoldedAccount) return false } @@ -168,7 +168,7 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo credentialValue = msg.Params[3] } else { client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, "Not enough parameters") - removeFailedRegCreateData(server.store, casefoldedAccount) + removeFailedAccRegisterData(server.store, casefoldedAccount) return false } @@ -180,14 +180,14 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo } } if credentialType == "certfp" && client.certfp == "" { - client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "You are not using a certificate") - removeFailedRegCreateData(server.store, casefoldedAccount) + client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "You are not using a certificiate") + removeFailedAccRegisterData(server.store, casefoldedAccount) return false } if !credentialValid { client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "Credential type is not supported") - removeFailedRegCreateData(server.store, casefoldedAccount) + removeFailedAccRegisterData(server.store, casefoldedAccount) return false } @@ -238,9 +238,9 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo if err == errCertfpAlreadyExists { errMsg = "An account already exists for your certificate fingerprint" } - client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REG", "CREATE", errMsg) + client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", errMsg) log.Println("Could not save registration creds:", err.Error()) - removeFailedRegCreateData(server.store, casefoldedAccount) + removeFailedAccRegisterData(server.store, casefoldedAccount) return false } @@ -265,9 +265,9 @@ func regCreateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) boo return nil }) if err != nil { - client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REG", "CREATE", "Could not register") + client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", "Could not register") log.Println("Could not save verification confirmation (*):", err.Error()) - removeFailedRegCreateData(server.store, casefoldedAccount) + removeFailedAccRegisterData(server.store, casefoldedAccount) return false } diff --git a/irc/commands.go b/irc/commands.go index d33f42b0..9a0a5c14 100644 --- a/irc/commands.go +++ b/irc/commands.go @@ -56,6 +56,10 @@ func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) b // Commands holds all commands executable by a client connected to us. var Commands = map[string]Command{ + "ACC": { + handler: accHandler, + minParams: 3, + }, "AMBIANCE": { handler: sceneHandler, minParams: 2, @@ -227,10 +231,6 @@ var Commands = map[string]Command{ usablePreReg: true, minParams: 0, }, - "REG": { - handler: regHandler, - minParams: 3, - }, "REHASH": { handler: rehashHandler, minParams: 0, diff --git a/irc/help.go b/irc/help.go index 20d7e82d..691f7940 100644 --- a/irc/help.go +++ b/irc/help.go @@ -67,6 +67,13 @@ Oragono supports the following user modes: // Help contains the help strings distributed with the IRCd. var Help = map[string]HelpEntry{ // Commands + "acc": { + text: `ACC REGISTER [callback_namespace:] [cred_type] : +ACC VERIFY + +Used in account registration. See the relevant specs for more info: +http://oragono.io/specs.html`, + }, "ambiance": { text: `AMBIANCE @@ -350,13 +357,6 @@ specs for more info: http://ircv3.net/specs/core/message-tags-3.3.html`, text: `QUIT [reason] Indicates that you're leaving the server, and shows everyone the given reason.`, - }, - "reg": { - text: `REG CREATE [callback_namespace:] [cred_type] : -REG VERIFY - -Used in account registration. See the relevant specs for more info: -http://oragono.io/specs.html`, }, "rehash": { oper: true,