3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

Merge pull request #1852 from slingamn/fail_authenticate

add FAIL AUTHENTICATE VERIFICATION_REQUIRED
This commit is contained in:
Shivaram Lingamneni 2021-11-30 20:35:33 -05:00 committed by GitHub
commit 72959eb1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,8 +269,7 @@ func authPlainHandler(server *Server, client *Client, session *Session, value []
password := string(splitValue[2])
err := server.accounts.AuthenticateByPassphrase(client, authcid, password)
if err != nil {
msg := authErrorToMessage(server, err)
rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(), fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
sendAuthErrorResponse(client, rb, err)
return false
} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
return false
@ -280,6 +279,14 @@ func authPlainHandler(server *Server, client *Client, session *Session, value []
return false
}
func sendAuthErrorResponse(client *Client, rb *ResponseBuffer, err error) {
msg := authErrorToMessage(client.server, err)
rb.Add(nil, client.server.name, ERR_SASLFAIL, client.nick, fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
if err == errAccountUnverified {
rb.Add(nil, client.server.name, "FAIL", "AUTHENTICATE", "VERIFICATION_REQUIRED", "*", client.t(err.Error()))
}
}
func authErrorToMessage(server *Server, err error) (msg string) {
if throttled, ok := err.(*ThrottleError); ok {
return throttled.Error()
@ -329,8 +336,7 @@ func authExternalHandler(server *Server, client *Client, session *Session, value
}
if err != nil {
msg := authErrorToMessage(server, err)
rb.Add(nil, server.name, ERR_SASLFAIL, client.nick, fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
sendAuthErrorResponse(client, rb, err)
return false
} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
return false