3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 07:29:31 +01:00

fix: store the uncasefolded account name correctly

This commit is contained in:
Shivaram Lingamneni 2018-02-20 04:50:46 -05:00
parent df41f9b3b0
commit 878f9ca94c
2 changed files with 11 additions and 13 deletions

View File

@ -578,18 +578,10 @@ type rawClientAccount struct {
// LoginToAccount logs the client into the given account.
func (client *Client) LoginToAccount(account string) {
casefoldedAccount, err := CasefoldName(account)
if err != nil {
return
changed := client.SetAccountName(account)
if changed {
client.nickTimer.Touch()
}
if client.Account() == casefoldedAccount {
// already logged into this acct, no changing necessary
return
}
client.SetAccountName(casefoldedAccount)
client.nickTimer.Touch()
}
// LogoutOfAccount logs the client out of their current account.

View File

@ -125,15 +125,21 @@ func (client *Client) AccountName() string {
return client.accountName
}
func (client *Client) SetAccountName(account string) {
func (client *Client) SetAccountName(account string) (changed bool) {
var casefoldedAccount string
var err error
if account != "" {
casefoldedAccount, _ = CasefoldName(account)
if casefoldedAccount, err = CasefoldName(account); err != nil {
return
}
}
client.stateMutex.Lock()
defer client.stateMutex.Unlock()
changed = client.account != casefoldedAccount
client.account = casefoldedAccount
client.accountName = account
return
}
func (client *Client) HasMode(mode modes.Mode) bool {