mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
add FAIL AUTHENTICATE VERIFICATION_REQUIRED
From discussion with @emersion, this will help with UX if people try to log into their unverified accounts.
This commit is contained in:
parent
8995dd8842
commit
7d66368274
@ -265,8 +265,7 @@ func authPlainHandler(server *Server, client *Client, session *Session, value []
|
|||||||
password := string(splitValue[2])
|
password := string(splitValue[2])
|
||||||
err := server.accounts.AuthenticateByPassphrase(client, authcid, password)
|
err := server.accounts.AuthenticateByPassphrase(client, authcid, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := authErrorToMessage(server, err)
|
sendAuthErrorResponse(client, rb, err)
|
||||||
rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(), fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
|
|
||||||
return false
|
return false
|
||||||
} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
|
} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
|
||||||
return false
|
return false
|
||||||
@ -276,6 +275,14 @@ func authPlainHandler(server *Server, client *Client, session *Session, value []
|
|||||||
return false
|
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) {
|
func authErrorToMessage(server *Server, err error) (msg string) {
|
||||||
if throttled, ok := err.(*ThrottleError); ok {
|
if throttled, ok := err.(*ThrottleError); ok {
|
||||||
return throttled.Error()
|
return throttled.Error()
|
||||||
@ -325,8 +332,7 @@ func authExternalHandler(server *Server, client *Client, session *Session, value
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := authErrorToMessage(server, err)
|
sendAuthErrorResponse(client, rb, err)
|
||||||
rb.Add(nil, server.name, ERR_SASLFAIL, client.nick, fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
|
|
||||||
return false
|
return false
|
||||||
} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
|
} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user