Improve error message when downstream doesn't authenticate

git-svn-id: file:///srv/svn/repo/suika/trunk@753 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
contact 2021-12-07 08:40:02 +00:00
parent 4d4886e359
commit 9a91517fc5

View File

@ -1236,11 +1236,25 @@ func (dc *downstreamConn) register(ctx context.Context) error {
password := dc.password
dc.password = ""
if dc.user == nil {
if password == "" {
if dc.caps["sasl"] {
return ircError{&irc.Message{
Command: "FAIL",
Params: []string{"*", "ACCOUNT_REQUIRED", "Authentication required"},
}}
} else {
return ircError{&irc.Message{
Command: irc.ERR_PASSWDMISMATCH,
Params: []string{dc.nick, "Authentication required"},
}}
}
}
if err := dc.authenticate(ctx, dc.rawUsername, password); err != nil {
dc.logger.Printf("PASS authentication error for user %q: %v", dc.rawUsername, err)
return ircError{&irc.Message{
Command: irc.ERR_PASSWDMISMATCH,
Params: []string{"*", authErrorReason(err)},
Params: []string{dc.nick, authErrorReason(err)},
}}
}
}