diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index 7b6bd1b4b..9e6723952 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -1814,9 +1814,27 @@ private: { // If we're bursting then then the user was probably logged in // during a previous connection. - auto *nc = NickCore::Find(value); - if (nc) + auto *na = NickAlias::Find(value); + if (!na) + { + // Nick has been dropped, force the IRCd to deauth them. + IRCD->SendLogout(u); + return; + } + + NickCore *nc = na->nc; + if (na == nc->na) + { + // User is logged into their display nick. u->Login(nc); + } + else + { + // User is logged into a non-display nick, their display has + // probably expired due to a config change so reauthenticate + // them as their new display nick. + u->Identify(nc->na); + } } } diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index d53cff601..f38aebd89 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -329,9 +329,29 @@ struct IRCDMessageMetadata final } if (params[1].equals_cs("accountname")) { - NickCore *nc = NickCore::Find(params[2]); - if (nc) + // If we're bursting then then the user was probably logged in + // during a previous connection. + auto *na = NickAlias::Find(params[2]); + if (!na) + { + // Nick has been dropped, force the IRCd to deauth them. + IRCD->SendLogout(u); + return; + } + + NickCore *nc = na->nc; + if (na == nc->na) + { + // User is logged into their display nick. u->Login(nc); + } + else + { + // User is logged into a non-display nick, their display has + // probably expired due to a config change so reauthenticate + // them as their new display nick. + u->Identify(nc->na); + } } else if (params[1].equals_cs("certfp")) { diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index e0a01b8fa..a06971b59 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -227,11 +227,33 @@ struct IRCDMessageEncap final if (params[1].equals_cs("SU")) { User *u = User::Find(params[2]); - NickCore *nc = NickCore::Find(params[3]); - if (u && nc) + if (!u) + return; // Should never happen. + + // If we're bursting then then the user was probably logged in + // during a previous connection. + auto *na = NickAlias::Find(params[3]); + if (!na) { + // Nick has been dropped, force the IRCd to deauth them. + IRCD->SendLogout(u); + return; + } + + NickCore *nc = na->nc; + if (na == nc->na) + { + // User is logged into their display nick. u->Login(nc); } + else + { + // User is logged into a non-display nick, their display has + // probably expired due to a config change so reauthenticate + // them as their new display nick. + u->Identify(nc->na); + } + } /* diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 97636563f..462a91bab 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -156,11 +156,32 @@ struct IRCDMessageEncap final if (params[1] == "LOGIN" || params[1] == "SU") { User *u = source.GetUser(); + if (!u) + return; // Should never happen. - NickCore *nc = NickCore::Find(params[2]); - if (!nc) + // If we're bursting then then the user was probably logged in + // during a previous connection. + auto *na = NickAlias::Find(params[2]); + if (!na) + { + // Nick has been dropped, force the IRCd to deauth them. + IRCD->SendLogout(u); return; - u->Login(nc); + } + + NickCore *nc = na->nc; + if (na == nc->na) + { + // User is logged into their display nick. + u->Login(nc); + } + else + { + // User is logged into a non-display nick, their display has + // probably expired due to a config change so reauthenticate + // them as their new display nick. + u->Identify(nc->na); + } /* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if * their server isn't syncing) and then we receive this.. so tell them about it. diff --git a/modules/protocol/solanum.cpp b/modules/protocol/solanum.cpp index 35bf425c8..d6ca765b4 100644 --- a/modules/protocol/solanum.cpp +++ b/modules/protocol/solanum.cpp @@ -318,12 +318,32 @@ struct IRCDMessageEncap final if (params[1] == "LOGIN" || params[1] == "SU") { User *u = source.GetUser(); - NickCore *nc = NickCore::Find(params[2]); - - if (!u || !nc) + if (!u) return; - u->Login(nc); + // If we're bursting then then the user was probably logged in + // during a previous connection. + auto *na = NickAlias::Find(params[2]); + if (!na) + { + // Nick has been dropped, force the IRCd to deauth them. + IRCD->SendLogout(u); + return; + } + + NickCore *nc = na->nc; + if (na == nc->na) + { + // User is logged into their display nick. + u->Login(nc); + } + else + { + // User is logged into a non-display nick, their display has + // probably expired due to a config change so reauthenticate + // them as their new display nick. + u->Identify(nc->na); + } } // Received: :42XAAAAAE ENCAP * CERTFP :3f122a9cc7811dbad3566bf2cec3009007c0868f else if (params[1] == "CERTFP") diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp index ce975db44..047950268 100644 --- a/modules/protocol/unrealircd.cpp +++ b/modules/protocol/unrealircd.cpp @@ -1651,11 +1651,29 @@ public: } else { - // If we're bursting then then the user was probably logged - // in during a previous connection. - NickCore *nc = NickCore::Find(params[2]); - if (nc) + // If we're bursting then then the user was probably logged in + // during a previous connection. + auto *na = NickAlias::Find(params[2]); + if (!na) + { + // Nick has been dropped, force the IRCd to deauth them. + IRCD->SendLogout(u); + return; + } + + NickCore *nc = na->nc; + if (na == nc->na) + { + // User is logged into their display nick. u->Login(nc); + } + else + { + // User is logged into a non-display nick, their display has + // probably expired due to a config change so reauthenticate + // them as their new display nick. + u->Identify(nc->na); + } } } };