mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-15 00:19:29 +01:00
commit
4948b48b8f
@ -821,7 +821,7 @@ func (am *AccountManager) dispatchMailtoCallback(client *Client, account string,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (am *AccountManager) Verify(client *Client, account string, code string) error {
|
func (am *AccountManager) Verify(client *Client, account string, code string, admin bool) error {
|
||||||
casefoldedAccount, err := CasefoldName(account)
|
casefoldedAccount, err := CasefoldName(account)
|
||||||
var skeleton string
|
var skeleton string
|
||||||
if err != nil || account == "" || account == "*" {
|
if err != nil || account == "" || account == "*" {
|
||||||
@ -884,6 +884,7 @@ func (am *AccountManager) Verify(client *Client, account string, code string) er
|
|||||||
return errAccountAlreadyVerified
|
return errAccountAlreadyVerified
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !admin {
|
||||||
// actually verify the code
|
// actually verify the code
|
||||||
// a stored code of "" means a none callback / no code required
|
// a stored code of "" means a none callback / no code required
|
||||||
success := false
|
success := false
|
||||||
@ -897,6 +898,7 @@ func (am *AccountManager) Verify(client *Client, account string, code string) er
|
|||||||
if !success {
|
if !success {
|
||||||
return errAccountVerificationInvalidCode
|
return errAccountVerificationInvalidCode
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// verify the account
|
// verify the account
|
||||||
tx.Set(verifiedKey, "1", nil)
|
tx.Set(verifiedKey, "1", nil)
|
||||||
@ -964,7 +966,7 @@ func (am *AccountManager) Verify(client *Client, account string, code string) er
|
|||||||
func (am *AccountManager) SARegister(account, passphrase string) (err error) {
|
func (am *AccountManager) SARegister(account, passphrase string) (err error) {
|
||||||
err = am.Register(nil, account, "admin", "", passphrase, "")
|
err = am.Register(nil, account, "admin", "", passphrase, "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = am.Verify(nil, account, "")
|
err = am.Verify(nil, account, "", true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2632,7 +2632,7 @@ func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
|
|||||||
switch err {
|
switch err {
|
||||||
case nil:
|
case nil:
|
||||||
if callbackNamespace == "*" {
|
if callbackNamespace == "*" {
|
||||||
err := server.accounts.Verify(client, accountName, "")
|
err := server.accounts.Verify(client, accountName, "", true)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if client.registered {
|
if client.registered {
|
||||||
if !fixupNickEqualsAccount(client, rb, config, "") {
|
if !fixupNickEqualsAccount(client, rb, config, "") {
|
||||||
@ -2684,7 +2684,7 @@ func verifyHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
accountName, verificationCode := msg.Params[0], msg.Params[1]
|
accountName, verificationCode := msg.Params[0], msg.Params[1]
|
||||||
err := server.accounts.Verify(client, accountName, verificationCode)
|
err := server.accounts.Verify(client, accountName, verificationCode, false)
|
||||||
if err == nil && client.registered {
|
if err == nil && client.registered {
|
||||||
if !fixupNickEqualsAccount(client, rb, config, "") {
|
if !fixupNickEqualsAccount(client, rb, config, "") {
|
||||||
err = errNickAccountMismatch
|
err = errNickAccountMismatch
|
||||||
|
@ -164,7 +164,17 @@ SAREGISTER registers an account on someone else's behalf.
|
|||||||
This is for use in configurations that require SASL for all connections;
|
This is for use in configurations that require SASL for all connections;
|
||||||
an administrator can set use this command to set up user accounts.`,
|
an administrator can set use this command to set up user accounts.`,
|
||||||
helpShort: `$bSAREGISTER$b registers an account on someone else's behalf.`,
|
helpShort: `$bSAREGISTER$b registers an account on someone else's behalf.`,
|
||||||
enabled: servCmdRequiresAuthEnabled,
|
enabled: servCmdRequiresAuthEnabled, // deliberate
|
||||||
|
capabs: []string{"accreg"},
|
||||||
|
minParams: 1,
|
||||||
|
},
|
||||||
|
"saverify": {
|
||||||
|
handler: nsSaverifyHandler,
|
||||||
|
help: `Syntax: $bSAVERIFY <username>$b
|
||||||
|
|
||||||
|
SAVERIFY manually verifies an account that is pending verification.`,
|
||||||
|
helpShort: `$bSAREGISTER$b registers an account on someone else's behalf.`,
|
||||||
|
enabled: servCmdRequiresAuthEnabled, // deliberate
|
||||||
capabs: []string{"accreg"},
|
capabs: []string{"accreg"},
|
||||||
minParams: 1,
|
minParams: 1,
|
||||||
},
|
},
|
||||||
@ -996,7 +1006,7 @@ func nsRegisterHandler(service *ircService, server *Server, client *Client, comm
|
|||||||
err := server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, rb.session.certfp)
|
err := server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, rb.session.certfp)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if callbackNamespace == "*" {
|
if callbackNamespace == "*" {
|
||||||
err = server.accounts.Verify(client, account, "")
|
err = server.accounts.Verify(client, account, "", true)
|
||||||
if err == nil && fixupNickEqualsAccount(client, rb, config, service.prefix) {
|
if err == nil && fixupNickEqualsAccount(client, rb, config, service.prefix) {
|
||||||
sendSuccessfulRegResponse(service, client, rb)
|
sendSuccessfulRegResponse(service, client, rb)
|
||||||
}
|
}
|
||||||
@ -1038,6 +1048,16 @@ func nsSaregisterHandler(service *ircService, server *Server, client *Client, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func nsSaverifyHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
|
account := params[0]
|
||||||
|
err := server.accounts.Verify(nil, account, "", true)
|
||||||
|
if err == nil {
|
||||||
|
service.Notice(rb, fmt.Sprintf(client.t("Successfully verified account %s"), account))
|
||||||
|
} else {
|
||||||
|
service.Notice(rb, fmt.Sprintf(client.t("Failed to verify account %s: %v"), account, err.Error()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func nsUnregisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func nsUnregisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
erase := command == "erase"
|
erase := command == "erase"
|
||||||
|
|
||||||
@ -1106,7 +1126,7 @@ func nsUnregisterHandler(service *ircService, server *Server, client *Client, co
|
|||||||
|
|
||||||
func nsVerifyHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func nsVerifyHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
username, code := params[0], params[1]
|
username, code := params[0], params[1]
|
||||||
err := server.accounts.Verify(client, username, code)
|
err := server.accounts.Verify(client, username, code, false)
|
||||||
|
|
||||||
var errorMessage string
|
var errorMessage string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user