Fixed error messages in commands

This commit is contained in:
2026-04-17 13:12:22 +02:00
parent bb66fcc097
commit 49fa432411
6 changed files with 69 additions and 33 deletions

View File

@@ -6,7 +6,7 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/17 11:53:56 by aortigos #+# #+# */
/* Updated: 2026/04/17 11:56:21 by aortigos ### ########.fr */
/* Updated: 2026/04/17 13:04:05 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,16 +18,32 @@ void Server::cmd_pass(int fd, std::istringstream &ss)
ss >> args;
if (args == this->password)
if (clients[fd].isAuthenticated())
{
clients[fd].setAuthenticated(true);
std::string msg = "You have been authenticated!\r\n";
std::string msg = ":ircserv 462 "
+ clients[fd].getNick()
+ " :You may not reregister\r\n";
send(fd, msg.c_str(), msg.size(), 0);
return ;
}
else
if (args.empty())
{
send(fd, ERR_PASSWORD.c_str(), ERR_PASSWORD.size(), 0);
removeClient(fd);
std::string msg = ":ircserv 461 * PASS :Not enough parameters\r\n";
send(fd, msg.c_str(), msg.size(), 0);
return ;
}
if (args != this->password)
{
std::string msg = ":ircserv 464 * :Password incorrect\r\n";
send(fd, msg.c_str(), msg.size(), 0);
removeClient(fd);
return ;
}
clients[fd].setAuthenticated(true);
}