mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 19:22:41 +01:00
Merge pull request #1742 from slingamn/register_update
update draft/register -> draft/account-registration
This commit is contained in:
commit
29f1afd565
@ -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",
|
||||
),
|
||||
]
|
||||
|
||||
|
@ -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",
|
||||
|
@ -246,7 +246,7 @@ func init() {
|
||||
},
|
||||
"REGISTER": {
|
||||
handler: registerHandler,
|
||||
minParams: 2,
|
||||
minParams: 3,
|
||||
usablePreReg: true,
|
||||
},
|
||||
"RENAME": {
|
||||
|
@ -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, ",")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 == "*" {
|
||||
|
2
irctest
2
irctest
@ -1 +1 @@
|
||||
Subproject commit 0b17fc84606ce8e1d52b04ad569b99f8d12e0b04
|
||||
Subproject commit a29b7c5631bfce49276d62578bffa2b19e56ab10
|
Loading…
Reference in New Issue
Block a user