Files
ft_irc/cmds/pass.cpp

32 lines
1.3 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pass.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/10 22:06:22 by aortigos #+# #+# */
/* Updated: 2026/05/10 22:39:03 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Server/Server.hpp"
void Server::pass_cmd(User &client, std::istringstream &ss)
{
std::string args;
ss >> args;
if (client.isAuthenticated())
{
std::string res = "You are already authenticated";
send(client.getFd(), res.c_str(), res.size(), 0);
return ;
}
if (this->password_ == args)
client->authenticated = true;
else {
std::string res = "Invalid password";
send(client.getFd(), res.c_str(), res.size(), 0);
}
}