Sfoglia il codice sorgente

add FAIL AUTHENTICATE VERIFICATION_REQUIRED

From discussion with @emersion, this will help with UX if people try to
log into their unverified accounts.
tags/v2.9.0-rc1
Shivaram Lingamneni 2 anni fa
parent
commit
7d66368274
1 ha cambiato i file con 10 aggiunte e 4 eliminazioni
  1. 10
    4
      irc/handlers.go

+ 10
- 4
irc/handlers.go Vedi File

@@ -265,8 +265,7 @@ func authPlainHandler(server *Server, client *Client, session *Session, value []
265 265
 	password := string(splitValue[2])
266 266
 	err := server.accounts.AuthenticateByPassphrase(client, authcid, password)
267 267
 	if err != nil {
268
-		msg := authErrorToMessage(server, err)
269
-		rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(), fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
268
+		sendAuthErrorResponse(client, rb, err)
270 269
 		return false
271 270
 	} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
272 271
 		return false
@@ -276,6 +275,14 @@ func authPlainHandler(server *Server, client *Client, session *Session, value []
276 275
 	return false
277 276
 }
278 277
 
278
+func sendAuthErrorResponse(client *Client, rb *ResponseBuffer, err error) {
279
+	msg := authErrorToMessage(client.server, err)
280
+	rb.Add(nil, client.server.name, ERR_SASLFAIL, client.nick, fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
281
+	if err == errAccountUnverified {
282
+		rb.Add(nil, client.server.name, "FAIL", "AUTHENTICATE", "VERIFICATION_REQUIRED", "*", client.t(err.Error()))
283
+	}
284
+}
285
+
279 286
 func authErrorToMessage(server *Server, err error) (msg string) {
280 287
 	if throttled, ok := err.(*ThrottleError); ok {
281 288
 		return throttled.Error()
@@ -325,8 +332,7 @@ func authExternalHandler(server *Server, client *Client, session *Session, value
325 332
 	}
326 333
 
327 334
 	if err != nil {
328
-		msg := authErrorToMessage(server, err)
329
-		rb.Add(nil, server.name, ERR_SASLFAIL, client.nick, fmt.Sprintf("%s: %s", client.t("SASL authentication failed"), client.t(msg)))
335
+		sendAuthErrorResponse(client, rb, err)
330 336
 		return false
331 337
 	} else if !fixupNickEqualsAccount(client, rb, server.Config(), "") {
332 338
 		return false

Loading…
Annulla
Salva