From 9ff4047fa650bc9873e58b7d8d6faf58df72922d Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 30 Nov 2021 01:50:28 -0500 Subject: [PATCH] fix #1840 Account registrations pending verification should produce a logline and send a sno. --- irc/accounts.go | 2 ++ irc/handlers.go | 5 +++++ irc/nickserv.go | 1 + 3 files changed, 8 insertions(+) diff --git a/irc/accounts.go b/irc/accounts.go index 2498ffa2..331b0cde 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -474,6 +474,8 @@ func (am *AccountManager) Register(client *Client, account string, callbackNames am.Unregister(casefoldedAccount, true) return ®istrationCallbackError{underlying: err} } else { + am.server.logger.Info("accounts", + fmt.Sprintf("nickname %s registered account %s, pending verification", client.Nick(), account)) return am.server.store.Update(func(tx *buntdb.Tx) error { _, _, err = tx.Set(verificationCodeKey, code, setOptions) return err diff --git a/irc/handlers.go b/irc/handlers.go index 820add90..0fb4436c 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -81,6 +81,10 @@ func registrationErrorToMessage(config *Config, client *Client, err error) (mess return } +func announcePendingReg(client *Client, rb *ResponseBuffer, accountName string) { + client.server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Client $c[grey][$r%s$c[grey]] attempted to register account $c[grey][$r%s$c[grey]] from IP %s, pending verification"), client.Nick(), accountName, rb.session.IP().String())) +} + // helper function to dispatch messages when a client successfully registers func sendSuccessfulRegResponse(service *ircService, client *Client, rb *ResponseBuffer) { details := client.Details() @@ -2632,6 +2636,7 @@ func registerHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res } else { rb.Add(nil, server.name, "REGISTER", "VERIFICATION_REQUIRED", accountName, fmt.Sprintf(client.t("Account created, pending verification; verification code has been sent to %s"), callbackValue)) client.registerCmdSent = true + announcePendingReg(client, rb, accountName) } case errAccountAlreadyRegistered, errAccountAlreadyUnregistered, errAccountMustHoldNick: rb.Add(nil, server.name, "FAIL", "REGISTER", "USERNAME_EXISTS", accountName, client.t("Username is already registered or otherwise unavailable")) diff --git a/irc/nickserv.go b/irc/nickserv.go index c9b4fda1..f450f3fd 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -1004,6 +1004,7 @@ func nsRegisterHandler(service *ircService, server *Server, client *Client, comm messageTemplate := client.t("Account created, pending verification; verification code has been sent to %s") message := fmt.Sprintf(messageTemplate, callbackValue) service.Notice(rb, message) + announcePendingReg(client, rb, account) } } else { // details could not be stored and relevant numerics have been dispatched, abort