cmds folder created and first version of pass cmd

This commit is contained in:
aortigos
2026-05-10 22:44:27 +02:00
parent c61e0826c6
commit 2f995fe856
2 changed files with 45 additions and 10 deletions

32
cmds/pass.cpp Normal file
View File

@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}
}