IRC SERVER
The goal of this project is to make you write your own IRC server.
Pass.hpp
Go to the documentation of this file.
1 #ifndef PASS_H
2 #define PASS_H
3 
4 // Our includes
5 #include "../Command.hpp"
6 
7 class Pass : public Command
8 {
9  public:
10  Pass()
11  {
12  _name = "pass";
13  _description = "inicia sesion con el pass";
14  _usage = "pass <password>";
15  _example[0] = "pass 1234";
16  _needs_auth = false;
17  }
18 
19  // ERR_NEEDMOREPARAMS comprobar tras arreglar nick
20 
21  bool validate(void)
22  {
23  std::map<size_t, std::string> p = _message->getParams();
24  if (p.size() < 1)
25  {
27  _message->getCmd()));
28  return (false);
29  }
30  if (_sender->isAuthenticated())
31  {
33  return (false);
34  }
35  if(_server->getPassword() == "")
36  {
38  return (false);
39 
40  }
41  if(_server->getPassword() != _message->getParams()[0])
42  {
44  return (false);
45  }
46 
47  return (true);
48  }
49 
50  void execute()
51  {
52  _sender->_is_passLogged=true;
53  if((_sender->getUsername() != "" && _sender->getRealname() != ""))
55 
56 
57  }
58 };
59 #endif
Pass
Definition: Pass.hpp:7
Pass::Pass
Pass()
Definition: Pass.hpp:10
Command::_description
std::string _description
Definition: Command.hpp:12
Command::_name
std::string _name
Definition: Command.hpp:11
Command
Definition: Command.hpp:7
Message::getCmd
std::string getCmd(void) const
Definition: message.cpp:74
Client::message
void message(char const *message)
Definition: client.cpp:15
Pass::validate
bool validate(void)
Definition: Pass.hpp:21
Client::isAuthenticated
bool isAuthenticated(void) const
Definition: Client.hpp:132
ERR_ALREADYREGISTRED
#define ERR_ALREADYREGISTRED(servername, nick)
Definition: Replies.hpp:133
Command::_needs_auth
bool _needs_auth
Definition: Command.hpp:15
Client::getUsername
const std::string getUsername(void) const
Definition: Client.hpp:147
Command::_message
Message * _message
Definition: Command.hpp:21
Server::getPassword
const std::string getPassword(void)
Definition: Server.hpp:83
ERR_NEEDMOREPARAMS
#define ERR_NEEDMOREPARAMS(servername, nick, command)
Definition: Replies.hpp:131
Command::_example
std::map< size_t, std::string > _example
Definition: Command.hpp:16
Pass::execute
void execute()
Definition: Pass.hpp:50
Client::_is_passLogged
bool _is_passLogged
Definition: Client.hpp:36
Message::getParams
std::map< size_t, std::string > getParams(void) const
Definition: message.cpp:79
ERR_WRONGPASS
#define ERR_WRONGPASS(servername, nick)
Definition: Replies.hpp:182
Command::_usage
std::string _usage
Definition: Command.hpp:13
ERR_NOTPASSNEEDED
#define ERR_NOTPASSNEEDED(servername, nick)
Definition: Replies.hpp:184
Command::_sender
Client * _sender
Definition: Command.hpp:19
Client::getRealname
const std::string getRealname(void) const
Definition: Client.hpp:152
Client::_nick
std::string _nick
Definition: Client.hpp:26
Client::_servername
std::string _servername
Definition: Client.hpp:30
Client::authenticate
void authenticate(void)
Definition: Client.hpp:98
Command::_server
Server * _server
Definition: Command.hpp:20