49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* pass.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/04/17 11:53:56 by aortigos #+# #+# */
|
|
/* Updated: 2026/04/17 13:04:05 by aortigos ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "../Server/Server.hpp"
|
|
|
|
void Server::cmd_pass(int fd, std::istringstream &ss)
|
|
{
|
|
std::string args;
|
|
|
|
ss >> args;
|
|
|
|
if (clients[fd].isAuthenticated())
|
|
{
|
|
std::string msg = ":ircserv 462 "
|
|
+ clients[fd].getNick()
|
|
+ " :You may not reregister\r\n";
|
|
send(fd, msg.c_str(), msg.size(), 0);
|
|
|
|
return ;
|
|
}
|
|
|
|
if (args.empty())
|
|
{
|
|
std::string msg = ":ircserv 461 * PASS :Not enough parameters\r\n";
|
|
send(fd, msg.c_str(), msg.size(), 0);
|
|
|
|
return ;
|
|
}
|
|
|
|
if (args != this->password)
|
|
{
|
|
std::string msg = ":ircserv 464 * :Password incorrect\r\n";
|
|
send(fd, msg.c_str(), msg.size(), 0);
|
|
removeClient(fd);
|
|
return ;
|
|
}
|
|
|
|
clients[fd].setAuthenticated(true);
|
|
|
|
} |