3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-15 00:19:29 +01:00

update draft/register -> draft/account-registration

Fixes #1740
This commit is contained in:
Shivaram Lingamneni 2021-07-07 07:37:46 -04:00
parent dcfd8d8fe8
commit 59bddd066f
5 changed files with 24 additions and 15 deletions

View File

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

View File

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

View File

@ -246,7 +246,7 @@ func init() {
},
"REGISTER": {
handler: registerHandler,
minParams: 2,
minParams: 3,
usablePreReg: true,
},
"RENAME": {

View File

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

View File

@ -2486,12 +2486,21 @@ func quitHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons
return true
}
// REGISTER < email | * > <password>
// REGISTER < account | * > < email | * > <password>
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 == "*" {