cmds folder created and first version of pass cmd
This commit is contained in:
32
cmds/pass.cpp
Normal file
32
cmds/pass.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user