pass-command #16

Merged
aortigos merged 2 commits from pass-command into main 2026-05-10 20:46:08 +00:00
2 changed files with 47 additions and 10 deletions

34
cmds/pass.cpp Normal file
View File

@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pass.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/10 22:06:22 by aortigos #+# #+# */
/* Updated: 2026/05/10 22:45:31 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
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 {
// Still need to find what server should reply to different errors
std::string res = "Invalid password";
send(client.getFd(), res.c_str(), res.size(), 0);
}
}

View File

@@ -29,24 +29,27 @@ Represents a connected IRC client.
### First stage
- Server starts
- It accepts two params, ./ircserv <port> <password>
- The server accepts one user, user can send messages and we can see from server
- Only 1 poll()
- [✓] Server starts
- [✓] It accepts two params, ./ircserv <port> <password>
- [✓] The server accepts one user, user can send messages and we can see from server
- [✓] Only 1 poll()
### Second stage
- Server can handle multiple clients simultaneously
- [✓] Server can handle multiple clients simultaneously
- [ ] Manage SO_REUSEADDR (restarting server fails to bind same port)
### Third stage
- Client has nickname and username
- Client needs password for authenticate
- Client can be regular user or operator (admin)
- [ ] Client has nickname and username
- [ ] Implement generic parser (extract command and pass args to command function)
- [ ] Dispatcher (select function for each command)
- [ ] PASS command for authenticate
### Fourth stage
- Client can create/connect to channels
- Client can send message inside channel (only people inside this channel can read)
- [ ] Client can create/connect to channels
- [ ] JOIN command (user can create channel)
- [ ] PRIVMSG command (send message to a channel)
*It will continue...*