diff --git a/modules/nickserv/nickserv.rs b/modules/nickserv/nickserv.rs index f9359c6..bb2bdbe 100644 --- a/modules/nickserv/nickserv.rs +++ b/modules/nickserv/nickserv.rs @@ -50,6 +50,12 @@ impl Service for NickServ { return; } }; + // Distinguish an unregistered account from a wrong password, so a + // failed login says which it was. + if !db.exists(account_name) { + ctx.notice(me, from.uid, format!("\x02{account_name}\x02 isn't registered.")); + return; + } match db.authenticate(account_name, password) { Some(account) => { // Already identified to this account: don't re-fire the login. diff --git a/src/engine/mod.rs b/src/engine/mod.rs index f8980bb..6c7c153 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -995,6 +995,12 @@ mod tests { }); assert!(bad.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("Invalid password"))), "{bad:?}"); assert!(!bad.iter().any(|a| matches!(a, NetAction::Metadata { .. })), "wrong password must not log in: {bad:?}"); + + // An unregistered account says so, rather than "Invalid password". + let missing = e.handle(NetEvent::Privmsg { + from: "000AAAAAC".into(), to: "42SAAAAAA".into(), text: "IDENTIFY ghost whatever".into(), + }); + assert!(missing.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("isn't registered"))), "{missing:?}"); } // ChanServ: registration needs identification, INFO shows the founder, and