mirror of
https://github.com/ergochat/ergo.git
synced 2025-02-18 06:30:39 +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
|
// clients can't reg new accounts if they're already logged in
|
||||||
if client.account != nil {
|
if client.LoggedIntoAccount() {
|
||||||
if server.accountRegistration.AllowMultiplePerConnection {
|
if server.accountRegistration.AllowMultiplePerConnection {
|
||||||
client.LogoutOfAccount()
|
client.LogoutOfAccount()
|
||||||
} else {
|
} else {
|
||||||
|
@ -248,7 +248,7 @@ func (client *Client) LoginToAccount(account *ClientAccount) {
|
|||||||
if client.account == account {
|
if client.account == account {
|
||||||
// already logged into this acct, no changing necessary
|
// already logged into this acct, no changing necessary
|
||||||
return
|
return
|
||||||
} else if client.account != nil {
|
} else if client.LoggedIntoAccount() {
|
||||||
// logout of existing acct
|
// logout of existing acct
|
||||||
var newClientAccounts []*Client
|
var newClientAccounts []*Client
|
||||||
for _, c := range account.Clients {
|
for _, c := range account.Clients {
|
||||||
@ -294,7 +294,7 @@ func (client *Client) LogoutOfAccount() {
|
|||||||
// 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 == "" {
|
||||||
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +479,11 @@ func (client *Client) ChangeNickname(nickname string) error {
|
|||||||
return err
|
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).
|
// Quit sends the given quit message to the client (but does not destroy them).
|
||||||
func (client *Client) Quit(message string) {
|
func (client *Client) Quit(message string) {
|
||||||
client.quitMutex.Lock()
|
client.quitMutex.Lock()
|
||||||
|
@ -820,7 +820,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
var canEdit bool
|
var canEdit bool
|
||||||
server.store.Update(func(tx *buntdb.Tx) error {
|
server.store.Update(func(tx *buntdb.Tx) error {
|
||||||
chanReg := server.loadChannelNoMutex(tx, casefoldedOldName)
|
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
|
canEdit = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user