From e95cd8221185679ec4e1f3ec181f6a4160132871 Mon Sep 17 00:00:00 2001 From: aortigos Date: Fri, 15 May 2026 22:09:14 +0200 Subject: [PATCH] less lines, same code --- cmds/nick.cpp | 11 ++++------- cmds/pass.cpp | 12 +++++------- cmds/user.cpp | 8 +++----- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/cmds/nick.cpp b/cmds/nick.cpp index 8313bd3..d0a0631 100644 --- a/cmds/nick.cpp +++ b/cmds/nick.cpp @@ -6,7 +6,7 @@ /* By: aortigos > args; - if (!client.isAuthenticated()) - return (client.send(":" SERVER_NAME " 451 * :You have not registered\r\n")); - if (args.empty()) - return (client.send(":" SERVER_NAME " 431 * :Not nickname given\r\n")); - if (!isValidNick(args)) - return (client.send(":" SERVER_NAME " 432 * " + args + " Erroneous nickname\r\n")); + if (!client.isAuthenticated()) return (client.send(":" SERVER_NAME " 451 * :You have not registered\r\n")); + if (args.empty()) return (client.send(":" SERVER_NAME " 431 * :Not nickname given\r\n")); + if (!isValidNick(args)) return (client.send(":" SERVER_NAME " 432 * " + args + " Erroneous nickname\r\n")); for (std::map::iterator it = clients_.begin(); it != clients_.end(); it++) { if (it->second.getNick() == args) diff --git a/cmds/pass.cpp b/cmds/pass.cpp index d842bd5..cd69772 100644 --- a/cmds/pass.cpp +++ b/cmds/pass.cpp @@ -6,7 +6,7 @@ /* By: aortigos > args; - if (args.empty()) - return (client.send(":" SERVER_NAME " 461 * PASS :Not enough parameters\r\n")); - if (client.isAuthenticated()) - return (client.send(":" SERVER_NAME " 462 " + client.getNick() + " :Unauthorized command (already registered)\r\n")); + if (args.empty()) return (client.send(":" SERVER_NAME " 461 * PASS :Not enough parameters\r\n")); + if (client.isAuthenticated()) return (client.send(":" SERVER_NAME " 462 " + client.getNick() + " :Unauthorized command (already registered)\r\n")); + if (this->password_ == args) client.setAuthenticated(true); - else { + else client.send(":" SERVER_NAME " 464 * :Password incorrect\r\n"); - } } \ No newline at end of file diff --git a/cmds/user.cpp b/cmds/user.cpp index f15a51f..a4be398 100644 --- a/cmds/user.cpp +++ b/cmds/user.cpp @@ -6,7 +6,7 @@ /* By: aortigos > username >> hostname >> servername; std::getline(ss, realname); - if (!client.isAuthenticated()) - return (client.send(":" SERVER_NAME " 451 * :You have not registered\r\n")); - if (client.isRegistered()) - return (client.send(":" SERVER_NAME " 462 " + client.getNick() + " :Unauthorized command (already registered)\r\n")); + if (!client.isAuthenticated()) return (client.send(":" SERVER_NAME " 451 * :You have not registered\r\n")); + if (client.isRegistered()) return (client.send(":" SERVER_NAME " 462 " + client.getNick() + " :Unauthorized command (already registered)\r\n")); if (!realname.empty() && realname[0] == ' ') realname = realname.substr(1); -- 2.49.1