mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
can't reserve a nick that's the name of an unverified account
This commit is contained in:
parent
47b9fe50be
commit
679f25491c
@ -386,7 +386,17 @@ func (am *AccountManager) SetNickReserved(client *Client, nick string, reserve b
|
|||||||
}
|
}
|
||||||
|
|
||||||
nicksKey := fmt.Sprintf(keyAccountAdditionalNicks, account)
|
nicksKey := fmt.Sprintf(keyAccountAdditionalNicks, account)
|
||||||
|
unverifiedAccountKey := fmt.Sprintf(keyAccountExists, cfnick)
|
||||||
err = am.server.store.Update(func(tx *buntdb.Tx) error {
|
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)
|
rawNicks, err := tx.Get(nicksKey)
|
||||||
if err != nil && err != buntdb.ErrNotFound {
|
if err != nil && err != buntdb.ErrNotFound {
|
||||||
return err
|
return err
|
||||||
@ -414,7 +424,7 @@ func (am *AccountManager) SetNickReserved(client *Client, nick string, reserve b
|
|||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
if err == errAccountTooManyNicks {
|
if err == errAccountTooManyNicks || err == errNicknameReserved {
|
||||||
return err
|
return err
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return errAccountNickReservationFailed
|
return errAccountNickReservationFailed
|
||||||
|
Loading…
Reference in New Issue
Block a user