From 679f25491cb9f4dcb98a20f4ae1b10bb8ae27ffe Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 11 Mar 2018 14:12:07 -0400 Subject: [PATCH] can't reserve a nick that's the name of an unverified account --- irc/accounts.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/irc/accounts.go b/irc/accounts.go index 8d3025f0..032a724f 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -386,7 +386,17 @@ func (am *AccountManager) SetNickReserved(client *Client, nick string, reserve b } nicksKey := fmt.Sprintf(keyAccountAdditionalNicks, account) + unverifiedAccountKey := fmt.Sprintf(keyAccountExists, cfnick) err = am.server.store.Update(func(tx *buntdb.Tx) error { + if reserve { + // unverified accounts don't show up in NickToAccount yet (which is intentional), + // however you shouldn't be able to reserve a nick out from under them + _, err := tx.Get(unverifiedAccountKey) + if err == nil { + return errNicknameReserved + } + } + rawNicks, err := tx.Get(nicksKey) if err != nil && err != buntdb.ErrNotFound { return err @@ -414,7 +424,7 @@ func (am *AccountManager) SetNickReserved(client *Client, nick string, reserve b return err }) - if err == errAccountTooManyNicks { + if err == errAccountTooManyNicks || err == errNicknameReserved { return err } else if err != nil { return errAccountNickReservationFailed