|
@@ -110,16 +110,17 @@ INFO gives you information about the given (or your own) user account.`,
|
110
|
110
|
handler: nsRegisterHandler,
|
111
|
111
|
// TODO: "email" is an oversimplification here; it's actually any callback, e.g.,
|
112
|
112
|
// person@example.com, mailto:person@example.com, tel:16505551234.
|
113
|
|
- help: `Syntax: $bREGISTER <username> <email> [password]$b
|
|
113
|
+ help: `Syntax: $bREGISTER <password> [email]$b
|
114
|
114
|
|
115
|
|
-REGISTER lets you register a user account. If the server allows anonymous
|
116
|
|
-registration, you can send an asterisk (*) as the email address.
|
|
115
|
+REGISTER lets you register your current nickname as a user account. If the
|
|
116
|
+server allows anonymous registration, you can omit the e-mail address.
|
117
|
117
|
|
118
|
|
-If the password is left out, your account will be registered to your TLS client
|
119
|
|
-certificate (and you will need to use that certificate to login in future).`,
|
|
118
|
+If you are currently logged in with a TLS client certificate and wish to use
|
|
119
|
+it instead of a password to log in, send * as the password.`,
|
120
|
120
|
helpShort: `$bREGISTER$b lets you register a user account.`,
|
121
|
121
|
enabled: servCmdRequiresAccreg,
|
122
|
|
- minParams: 2,
|
|
122
|
+ minParams: 1,
|
|
123
|
+ maxParams: 2,
|
123
|
124
|
},
|
124
|
125
|
"sadrop": {
|
125
|
126
|
handler: nsDropHandler,
|
|
@@ -586,20 +587,25 @@ func nsInfoHandler(server *Server, client *Client, command string, params []stri
|
586
|
587
|
}
|
587
|
588
|
|
588
|
589
|
func nsRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
589
|
|
- // get params
|
590
|
|
- account, email := params[0], params[1]
|
591
|
|
- var passphrase string
|
592
|
|
- if len(params) > 2 {
|
593
|
|
- passphrase = params[2]
|
|
590
|
+ details := client.Details()
|
|
591
|
+ account := details.nick
|
|
592
|
+ passphrase := params[0]
|
|
593
|
+ var email string
|
|
594
|
+ if 1 < len(params) {
|
|
595
|
+ email = params[1]
|
594
|
596
|
}
|
595
|
597
|
|
596
|
598
|
certfp := client.certfp
|
597
|
|
- if passphrase == "" && certfp == "" {
|
598
|
|
- nsNotice(rb, client.t("You need to either supply a passphrase or be connected via TLS with a client cert"))
|
599
|
|
- return
|
|
599
|
+ if passphrase == "*" {
|
|
600
|
+ if certfp == "" {
|
|
601
|
+ nsNotice(rb, client.t("You must be connected with TLS and a client certificate to do this"))
|
|
602
|
+ return
|
|
603
|
+ } else {
|
|
604
|
+ passphrase = ""
|
|
605
|
+ }
|
600
|
606
|
}
|
601
|
607
|
|
602
|
|
- if client.LoggedIntoAccount() {
|
|
608
|
+ if details.account != "" {
|
603
|
609
|
nsNotice(rb, client.t("You're already logged into an account"))
|
604
|
610
|
return
|
605
|
611
|
}
|
|
@@ -608,13 +614,6 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
608
|
614
|
return
|
609
|
615
|
}
|
610
|
616
|
|
611
|
|
- // band-aid to let users know if they mix up the order of registration params
|
612
|
|
- if email == "*" {
|
613
|
|
- nsNotice(rb, client.t("Registering your account with no email address"))
|
614
|
|
- } else {
|
615
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Registering your account with email address %s"), email))
|
616
|
|
- }
|
617
|
|
-
|
618
|
617
|
config := server.AccountConfig()
|
619
|
618
|
var callbackNamespace, callbackValue string
|
620
|
619
|
noneCallbackAllowed := false
|
|
@@ -630,7 +629,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
630
|
629
|
callbackNamespace = "*"
|
631
|
630
|
} else {
|
632
|
631
|
callbackNamespace, callbackValue = parseCallback(email, config)
|
633
|
|
- if callbackNamespace == "" {
|
|
632
|
+ if callbackNamespace == "" || callbackValue == "" {
|
634
|
633
|
nsNotice(rb, client.t("Registration requires a valid e-mail address"))
|
635
|
634
|
return
|
636
|
635
|
}
|