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

accounts: Check for account logins correctly, fixes registration. Also fix a typo, thanks squigz!

This commit is contained in:
Daniel Oaks 2017-09-28 15:49:01 +10:00
parent 90435256fd
commit cd8b4877b6
4 changed files with 9 additions and 4 deletions

View File

@ -95,7 +95,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
}
// clients can't reg new accounts if they're already logged in
if client.account != nil {
if client.LoggedIntoAccount() {
if server.accountRegistration.AllowMultiplePerConnection {
client.LogoutOfAccount()
} else {

View File

@ -248,7 +248,7 @@ func (client *Client) LoginToAccount(account *ClientAccount) {
if client.account == account {
// already logged into this acct, no changing necessary
return
} else if client.account != nil {
} else if client.LoggedIntoAccount() {
// logout of existing acct
var newClientAccounts []*Client
for _, c := range account.Clients {
@ -294,7 +294,7 @@ func (client *Client) LogoutOfAccount() {
// authExternalHandler parses the SASL EXTERNAL mechanism.
func authExternalHandler(server *Server, client *Client, mechanism string, value []byte) bool {
if client.certfp == "" {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed, you are not connecting with a caertificate")
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed, you are not connecting with a certificate")
return false
}

View File

@ -479,6 +479,11 @@ func (client *Client) ChangeNickname(nickname string) error {
return err
}
// LoggedIntoAccount returns true if this client is logged into an account.
func (client *Client) LoggedIntoAccount() bool {
return client.account != nil && client.account != &NoAccount
}
// Quit sends the given quit message to the client (but does not destroy them).
func (client *Client) Quit(message string) {
client.quitMutex.Lock()

View File

@ -820,7 +820,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
var canEdit bool
server.store.Update(func(tx *buntdb.Tx) error {
chanReg := server.loadChannelNoMutex(tx, casefoldedOldName)
if chanReg == nil || client.account == nil || client.account.Name == chanReg.Founder {
if chanReg == nil || !client.LoggedIntoAccount() || client.account.Name == chanReg.Founder {
canEdit = true
}