mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 21:39:25 +01:00
accounts: Check for account logins correctly, fixes registration. Also fix a typo, thanks squigz!
This commit is contained in:
parent
90435256fd
commit
cd8b4877b6
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user