diff --git a/cmds/pass.cpp b/cmds/pass.cpp new file mode 100644 index 0000000..f0256a6 --- /dev/null +++ b/cmds/pass.cpp @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pass.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: aortigos > 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); + } +} \ No newline at end of file diff --git a/tasks.md b/tasks.md index c934488..4fb28d8 100644 --- a/tasks.md +++ b/tasks.md @@ -29,24 +29,27 @@ Represents a connected IRC client. ### First stage -- Server starts -- It accepts two params, ./ircserv -- 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 +- [✓] 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...*