nickserv: IDENTIFY reports an unregistered account distinctly
A failed IDENTIFY now says whether the account isn't registered or the password was wrong, instead of one message for both.
This commit is contained in:
parent
914c3874ce
commit
4408281d20
2 changed files with 12 additions and 0 deletions
|
|
@ -50,6 +50,12 @@ impl Service for NickServ {
|
||||||
return;
|
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) {
|
match db.authenticate(account_name, password) {
|
||||||
Some(account) => {
|
Some(account) => {
|
||||||
// Already identified to this account: don't re-fire the login.
|
// Already identified to this account: don't re-fire the login.
|
||||||
|
|
|
||||||
|
|
@ -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::Notice { text, .. } if text.contains("Invalid password"))), "{bad:?}");
|
||||||
assert!(!bad.iter().any(|a| matches!(a, NetAction::Metadata { .. })), "wrong password must not log in: {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
|
// ChanServ: registration needs identification, INFO shows the founder, and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue