Pārlūkot izejas kodu

update draft/register -> draft/account-registration

Fixes #1740
tags/v2.8.0-rc1
Shivaram Lingamneni 2 gadus atpakaļ
vecāks
revīzija
59bddd066f
5 mainītis faili ar 24 papildinājumiem un 15 dzēšanām
  1. 4
    4
      gencapdefs.py
  2. 5
    5
      irc/caps/defs.go
  3. 1
    1
      irc/commands.go
  4. 2
    2
      irc/config.go
  5. 12
    3
      irc/handlers.go

+ 4
- 4
gencapdefs.py Parādīt failu

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

+ 5
- 5
irc/caps/defs.go Parādīt failu

@@ -37,6 +37,10 @@ const (
37 37
 	// https://ircv3.net/specs/extensions/chghost-3.2.html
38 38
 	ChgHost Capability = iota
39 39
 
40
+	// AccountRegistration is the draft IRCv3 capability named "draft/account-registration":
41
+	// https://github.com/ircv3/ircv3-specifications/pull/435
42
+	AccountRegistration Capability = iota
43
+
40 44
 	// ChannelRename is the draft IRCv3 capability named "draft/channel-rename":
41 45
 	// https://ircv3.net/specs/extensions/channel-rename
42 46
 	ChannelRename Capability = iota
@@ -57,10 +61,6 @@ const (
57 61
 	// https://github.com/ircv3/ircv3-specifications/pull/398
58 62
 	Multiline Capability = iota
59 63
 
60
-	// Register is the proposed IRCv3 capability named "draft/register":
61
-	// https://gist.github.com/edk0/bf3b50fc219fd1bed1aa15d98bfb6495
62
-	Register Capability = iota
63
-
64 64
 	// Relaymsg is the proposed IRCv3 capability named "draft/relaymsg":
65 65
 	// https://github.com/ircv3/ircv3-specifications/pull/417
66 66
 	Relaymsg Capability = iota
@@ -131,12 +131,12 @@ var (
131 131
 		"batch",
132 132
 		"cap-notify",
133 133
 		"chghost",
134
+		"draft/account-registration",
134 135
 		"draft/channel-rename",
135 136
 		"draft/chathistory",
136 137
 		"draft/event-playback",
137 138
 		"draft/languages",
138 139
 		"draft/multiline",
139
-		"draft/register",
140 140
 		"draft/relaymsg",
141 141
 		"echo-message",
142 142
 		"extended-join",

+ 1
- 1
irc/commands.go Parādīt failu

@@ -246,7 +246,7 @@ func init() {
246 246
 		},
247 247
 		"REGISTER": {
248 248
 			handler:      registerHandler,
249
-			minParams:    2,
249
+			minParams:    3,
250 250
 			usablePreReg: true,
251 251
 		},
252 252
 		"RENAME": {

+ 2
- 2
irc/config.go Parādīt failu

@@ -1385,7 +1385,7 @@ func LoadConfig(filename string) (config *Config, err error) {
1385 1385
 	}
1386 1386
 
1387 1387
 	if !config.Accounts.Registration.Enabled {
1388
-		config.Server.supportedCaps.Disable(caps.Register)
1388
+		config.Server.supportedCaps.Disable(caps.AccountRegistration)
1389 1389
 	} else {
1390 1390
 		var registerValues []string
1391 1391
 		if config.Accounts.Registration.AllowBeforeConnect {
@@ -1398,7 +1398,7 @@ func LoadConfig(filename string) (config *Config, err error) {
1398 1398
 			registerValues = append(registerValues, "account-required")
1399 1399
 		}
1400 1400
 		if len(registerValues) != 0 {
1401
-			config.Server.capValues[caps.Register] = strings.Join(registerValues, ",")
1401
+			config.Server.capValues[caps.AccountRegistration] = strings.Join(registerValues, ",")
1402 1402
 		}
1403 1403
 	}
1404 1404
 

+ 12
- 3
irc/handlers.go Parādīt failu

@@ -2486,12 +2486,21 @@ func quitHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons
2486 2486
 	return true
2487 2487
 }
2488 2488
 
2489
-// REGISTER < email | * > <password>
2489
+// REGISTER < account | * > < email | * > <password>
2490 2490
 func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) {
2491 2491
 	accountName := client.Nick()
2492 2492
 	if accountName == "*" {
2493 2493
 		accountName = client.preregNick
2494 2494
 	}
2495
+
2496
+	switch msg.Params[0] {
2497
+	case "*", accountName:
2498
+		// ok
2499
+	default:
2500
+		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"))
2501
+		return
2502
+	}
2503
+
2495 2504
 	// check that accountName is valid as a non-final parameter;
2496 2505
 	// this is necessary for us to be valid and it will prevent us from emitting invalid error lines
2497 2506
 	nickErrorParam := utils.SafeErrorParam(accountName)
@@ -2514,13 +2523,13 @@ func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
2514 2523
 		return
2515 2524
 	}
2516 2525
 
2517
-	callbackNamespace, callbackValue, err := parseCallback(msg.Params[0], config)
2526
+	callbackNamespace, callbackValue, err := parseCallback(msg.Params[1], config)
2518 2527
 	if err != nil {
2519 2528
 		rb.Add(nil, server.name, "FAIL", "REGISTER", "INVALID_EMAIL", accountName, client.t("A valid e-mail address is required"))
2520 2529
 		return
2521 2530
 	}
2522 2531
 
2523
-	err = server.accounts.Register(client, accountName, callbackNamespace, callbackValue, msg.Params[1], rb.session.certfp)
2532
+	err = server.accounts.Register(client, accountName, callbackNamespace, callbackValue, msg.Params[2], rb.session.certfp)
2524 2533
 	switch err {
2525 2534
 	case nil:
2526 2535
 		if callbackNamespace == "*" {

Notiek ielāde…
Atcelt
Saglabāt