|
@@ -610,23 +610,6 @@ func nsLoginThrottleCheck(client *Client, rb *ResponseBuffer) (success bool) {
|
610
|
610
|
return true
|
611
|
611
|
}
|
612
|
612
|
|
613
|
|
-// if force-nick-equals-account is set, account name and nickname must be equal,
|
614
|
|
-// so we need to re-NICK automatically on every login event (IDENTIFY,
|
615
|
|
-// VERIFY, and a REGISTER that auto-verifies). if we can't get the nick
|
616
|
|
-// then we log them out (they will be able to reattach with SASL)
|
617
|
|
-func nsFixNickname(client *Client, rb *ResponseBuffer, config *Config) (success bool) {
|
618
|
|
- if !config.Accounts.NickReservation.ForceNickEqualsAccount {
|
619
|
|
- return true
|
620
|
|
- }
|
621
|
|
- // don't need to supply a nickname, SetNick will use the account name
|
622
|
|
- if !performNickChange(client.server, client, client, rb.session, "", rb) {
|
623
|
|
- client.server.accounts.Logout(client)
|
624
|
|
- nsNotice(rb, client.t("A client is already using that account; try logging out and logging back in with SASL"))
|
625
|
|
- return false
|
626
|
|
- }
|
627
|
|
- return true
|
628
|
|
-}
|
629
|
|
-
|
630
|
613
|
func nsIdentifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
631
|
614
|
if client.LoggedIntoAccount() {
|
632
|
615
|
nsNotice(rb, client.t("You're already logged into an account"))
|
|
@@ -666,17 +649,19 @@ func nsIdentifyHandler(server *Server, client *Client, command string, params []
|
666
|
649
|
loginSuccessful = (err == nil)
|
667
|
650
|
}
|
668
|
651
|
|
|
652
|
+ nickFixupFailed := false
|
669
|
653
|
if loginSuccessful {
|
670
|
|
- if !nsFixNickname(client, rb, server.Config()) {
|
|
654
|
+ if !fixupNickEqualsAccount(client, rb, server.Config()) {
|
671
|
655
|
loginSuccessful = false
|
672
|
|
- err = errNickAccountMismatch
|
|
656
|
+ // fixupNickEqualsAccount sends its own error message, don't send another
|
|
657
|
+ nickFixupFailed = true
|
673
|
658
|
}
|
674
|
659
|
}
|
675
|
660
|
|
676
|
661
|
if loginSuccessful {
|
677
|
662
|
sendSuccessfulAccountAuth(client, rb, true, true)
|
678
|
|
- } else if err != errNickAccountMismatch {
|
679
|
|
- nsNotice(rb, client.t("Could not login with your TLS certificate or supplied username/password"))
|
|
663
|
+ } else if !nickFixupFailed {
|
|
664
|
+ nsNotice(rb, fmt.Sprintf(client.t("Authentication failed: %s"), authErrorToMessage(server, err)))
|
680
|
665
|
}
|
681
|
666
|
}
|
682
|
667
|
|
|
@@ -786,7 +771,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
786
|
771
|
if err == nil {
|
787
|
772
|
if callbackNamespace == "*" {
|
788
|
773
|
err = server.accounts.Verify(client, account, "")
|
789
|
|
- if err == nil && nsFixNickname(client, rb, config) {
|
|
774
|
+ if err == nil && fixupNickEqualsAccount(client, rb, config) {
|
790
|
775
|
sendSuccessfulRegResponse(client, rb, true)
|
791
|
776
|
}
|
792
|
777
|
} else {
|
|
@@ -892,7 +877,7 @@ func nsVerifyHandler(server *Server, client *Client, command string, params []st
|
892
|
877
|
return
|
893
|
878
|
}
|
894
|
879
|
|
895
|
|
- if nsFixNickname(client, rb, server.Config()) {
|
|
880
|
+ if fixupNickEqualsAccount(client, rb, server.Config()) {
|
896
|
881
|
sendSuccessfulRegResponse(client, rb, true)
|
897
|
882
|
}
|
898
|
883
|
}
|