One file per command

This commit is contained in:
2026-04-17 12:01:16 +02:00
parent 00a08b4f30
commit bb66fcc097
8 changed files with 169 additions and 4 deletions

33
commands/pass.cpp Normal file
View File

@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pass.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* 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 */
/* */
/* ************************************************************************** */
#include "../Server/Server.hpp"
void Server::cmd_pass(int fd, std::istringstream &ss)
{
std::string args;
ss >> args;
if (args == this->password)
{
clients[fd].setAuthenticated(true);
std::string msg = "You have been authenticated!\r\n";
send(fd, msg.c_str(), msg.size(), 0);
}
else
{
send(fd, ERR_PASSWORD.c_str(), ERR_PASSWORD.size(), 0);
removeClient(fd);
}
}