diff --git a/irc/accounts.go b/irc/accounts.go index 2d5ec8eb..75e69e5f 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -744,6 +744,7 @@ func (am *AccountManager) dispatchMailtoCallback(client *Client, account string, func (am *AccountManager) Verify(client *Client, account string, code string) error { casefoldedAccount, err := CasefoldName(account) + var skeleton string if err != nil || account == "" || account == "*" { return errAccountVerificationFailed } @@ -814,7 +815,7 @@ func (am *AccountManager) Verify(client *Client, account string, code string) er }) if err == nil { - skeleton, _ := Skeleton(raw.Name) + skeleton, _ = Skeleton(raw.Name) am.Lock() am.nickToAccount[casefoldedAccount] = casefoldedAccount am.skeletonToAccount[skeleton] = casefoldedAccount @@ -839,6 +840,18 @@ func (am *AccountManager) Verify(client *Client, account string, code string) er if client != nil { am.Login(client, clientAccount) } + _, method := am.EnforcementStatus(casefoldedAccount, skeleton) + if method != NickEnforcementNone { + currentClient := am.server.clients.Get(casefoldedAccount) + if currentClient == nil || currentClient == client || currentClient.Account() == casefoldedAccount { + return nil + } + if method == NickEnforcementStrict { + am.server.RandomlyRename(currentClient) + } else if method == NickEnforcementWithTimeout { + currentClient.nickTimer.Touch(nil) + } + } return nil } diff --git a/irc/nickname.go b/irc/nickname.go index 2dd7ae33..a49a2137 100644 --- a/irc/nickname.go +++ b/irc/nickname.go @@ -98,6 +98,10 @@ func (server *Server) RandomlyRename(client *Client) { nick := strings.Replace(format, "*", utils.B32Encoder.EncodeToString(buf), -1) sessions := client.Sessions() if len(sessions) == 0 { + // this can happen if they are anonymous and BRB (in general, an always-on + // client has title to its nickname and will never be the victim of + // a call to RandomlyRename) + client.destroy(nil) return } // XXX arbitrarily pick the first session to receive error messages;