Files
ft_irc/cmds/pass.cpp

33 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/14 17:23:56 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Server/Server.hpp"
void Server::pass_cmd(User &client, std::istringstream &ss)
{
std::string args;
ss >> args;
if (client.isAuthenticated())
{
// Still need to find what server should reply to different errors
client.send("You are already logged in\r\n");
return ;
}
if (this->password_ == args)
client.setAuthenticated(true);
else {
// Still need to find what server should reply to different errors
client.send("Invalid password\r\n");
send(client.getFd(), res.c_str(), res.size(), 0);
}
}