mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
accounts: Login to accounts properly
Avoids letting clients login to two accounts at once
This commit is contained in:
parent
27e36e4c6a
commit
3d597a4fb3
@ -22,6 +22,7 @@ New release of Oragono!
|
|||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
* Fixed an account issue where clients could login to multiple accounts at once.
|
||||||
|
|
||||||
|
|
||||||
## [0.6.0] - 2017-01-19
|
## [0.6.0] - 2017-01-19
|
||||||
|
@ -222,8 +222,7 @@ func authPlainHandler(server *Server, client *Client, mechanism string, value []
|
|||||||
account = loadAccount(server, tx, accountKey)
|
account = loadAccount(server, tx, accountKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
account.Clients = append(account.Clients, client)
|
client.LoginToAccount(account)
|
||||||
client.account = account
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
@ -237,6 +236,26 @@ func authPlainHandler(server *Server, client *Client, mechanism string, value []
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoginToAccount logs the client into the given account.
|
||||||
|
func (client *Client) LoginToAccount(account *ClientAccount) {
|
||||||
|
if client.account == account {
|
||||||
|
// already logged into this acct, no changing necessary
|
||||||
|
return
|
||||||
|
} else if client.account != nil {
|
||||||
|
// logout of existing acct
|
||||||
|
var newClientAccounts []*Client
|
||||||
|
for _, c := range account.Clients {
|
||||||
|
if c != client {
|
||||||
|
newClientAccounts = append(newClientAccounts, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
account.Clients = newClientAccounts
|
||||||
|
}
|
||||||
|
|
||||||
|
account.Clients = append(account.Clients, client)
|
||||||
|
client.account = account
|
||||||
|
}
|
||||||
|
|
||||||
// authExternalHandler parses the SASL EXTERNAL mechanism.
|
// authExternalHandler parses the SASL EXTERNAL mechanism.
|
||||||
func authExternalHandler(server *Server, client *Client, mechanism string, value []byte) bool {
|
func authExternalHandler(server *Server, client *Client, mechanism string, value []byte) bool {
|
||||||
if client.certfp == "" {
|
if client.certfp == "" {
|
||||||
@ -275,8 +294,7 @@ func authExternalHandler(server *Server, client *Client, mechanism string, value
|
|||||||
account = loadAccount(server, tx, accountKey)
|
account = loadAccount(server, tx, accountKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
account.Clients = append(account.Clients, client)
|
client.LoginToAccount(account)
|
||||||
client.account = account
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user