Files
ft_irc/cmds/pass.cpp
2026-05-15 22:09:14 +02:00

27 lines
1.4 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pass.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/10 22:06:22 by aortigos #+# #+# */
/* Updated: 2026/05/15 22:08:49 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Server/Server.hpp"
void Server::pass_cmd(User &client, std::istringstream &ss)
{
std::string args;
ss >> 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 (this->password_ == args)
client.setAuthenticated(true);
else
client.send(":" SERVER_NAME " 464 * :Password incorrect\r\n");
}