3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-11 12:42:37 +01:00

Merge pull request #1742 from slingamn/register_update

update draft/register -> draft/account-registration
This commit is contained in:
Shivaram Lingamneni 2021-07-07 09:17:20 -04:00 committed by GitHub
commit 29f1afd565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 16 deletions

View File

@ -172,10 +172,10 @@ CAPDEFS = [
standard="proposed IRCv3", standard="proposed IRCv3",
), ),
CapDef( CapDef(
identifier="Register", identifier="AccountRegistration",
name="draft/register", name="draft/account-registration",
url="https://gist.github.com/edk0/bf3b50fc219fd1bed1aa15d98bfb6495", url="https://github.com/ircv3/ircv3-specifications/pull/435",
standard="proposed IRCv3", standard="draft IRCv3",
), ),
] ]

View File

@ -37,6 +37,10 @@ const (
// https://ircv3.net/specs/extensions/chghost-3.2.html // https://ircv3.net/specs/extensions/chghost-3.2.html
ChgHost Capability = iota 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": // ChannelRename is the draft IRCv3 capability named "draft/channel-rename":
// https://ircv3.net/specs/extensions/channel-rename // https://ircv3.net/specs/extensions/channel-rename
ChannelRename Capability = iota ChannelRename Capability = iota
@ -57,10 +61,6 @@ const (
// https://github.com/ircv3/ircv3-specifications/pull/398 // https://github.com/ircv3/ircv3-specifications/pull/398
Multiline Capability = iota 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": // Relaymsg is the proposed IRCv3 capability named "draft/relaymsg":
// https://github.com/ircv3/ircv3-specifications/pull/417 // https://github.com/ircv3/ircv3-specifications/pull/417
Relaymsg Capability = iota Relaymsg Capability = iota
@ -131,12 +131,12 @@ var (
"batch", "batch",
"cap-notify", "cap-notify",
"chghost", "chghost",
"draft/account-registration",
"draft/channel-rename", "draft/channel-rename",
"draft/chathistory", "draft/chathistory",
"draft/event-playback", "draft/event-playback",
"draft/languages", "draft/languages",
"draft/multiline", "draft/multiline",
"draft/register",
"draft/relaymsg", "draft/relaymsg",
"echo-message", "echo-message",
"extended-join", "extended-join",

View File

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

View File

@ -1385,7 +1385,7 @@ func LoadConfig(filename string) (config *Config, err error) {
} }
if !config.Accounts.Registration.Enabled { if !config.Accounts.Registration.Enabled {
config.Server.supportedCaps.Disable(caps.Register) config.Server.supportedCaps.Disable(caps.AccountRegistration)
} else { } else {
var registerValues []string var registerValues []string
if config.Accounts.Registration.AllowBeforeConnect { if config.Accounts.Registration.AllowBeforeConnect {
@ -1398,7 +1398,7 @@ func LoadConfig(filename string) (config *Config, err error) {
registerValues = append(registerValues, "account-required") registerValues = append(registerValues, "account-required")
} }
if len(registerValues) != 0 { 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 return true
} }
// REGISTER < email | * > <password> // REGISTER < account | * > < email | * > <password>
func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) { func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) {
accountName := client.Nick() accountName := client.Nick()
if accountName == "*" { if accountName == "*" {
accountName = client.preregNick 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; // 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 // this is necessary for us to be valid and it will prevent us from emitting invalid error lines
nickErrorParam := utils.SafeErrorParam(accountName) nickErrorParam := utils.SafeErrorParam(accountName)
@ -2514,13 +2523,13 @@ func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
return return
} }
callbackNamespace, callbackValue, err := parseCallback(msg.Params[0], config) callbackNamespace, callbackValue, err := parseCallback(msg.Params[1], config)
if err != nil { if err != nil {
rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_EMAIL", accountName, client.t("A valid e-mail address is required")) rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_EMAIL", accountName, client.t("A valid e-mail address is required"))
return 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 { switch err {
case nil: case nil:
if callbackNamespace == "*" { if callbackNamespace == "*" {

@ -1 +1 @@
Subproject commit 0b17fc84606ce8e1d52b04ad569b99f8d12e0b04 Subproject commit a29b7c5631bfce49276d62578bffa2b19e56ab10