1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /** Handle /USER. These command handlers can be reloaded by the core,
17 * and handle basic RFC1459 commands. Commands within modules work
18 * the same way, however, they can be fully unloaded, where these
21 class CommandUser : public Command
24 /** Constructor for user.
26 CommandUser ( Module* parent) : Command(parent,"USER",4,4) { works_before_reg = true; Penalty = 0; syntax = "<username> <localhost> <remotehost> <GECOS>"; }
28 * @param parameters The parameters to the comamnd
29 * @param pcnt The number of parameters passed to teh command
30 * @param user The user issuing the command
31 * @return A value from CmdResult to indicate command success or failure.
33 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
36 CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User *user)
38 /* A user may only send the USER command once */
39 if (!(user->registered & REG_USER))
41 if (!ServerInstance->IsIdent(parameters[0].c_str()))
44 * RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :)
45 * -- Craig, and then w00t.
47 user->WriteNumeric(461, "%s USER :Your username is not valid",user->nick.c_str());
53 * The ident field is IDENTMAX+2 in size to account for +1 for the optional
54 * ~ character, and +1 for null termination, therefore we can safely use up to
57 user->ChangeIdent(parameters[0].c_str());
58 user->fullname.assign(parameters[3].empty() ? std::string("No info") : parameters[3], 0, ServerInstance->Config->Limits.MaxGecos);
59 user->registered = (user->registered | REG_USER);
64 user->WriteNumeric(462, "%s :You may not reregister", user->nick.c_str());
68 /* parameters 2 and 3 are local and remote hosts, and are ignored */
69 if (user->registered == REG_NICKUSER)
73 /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
74 FIRST_MOD_RESULT(ServerInstance, OnUserRegister, MOD_RESULT, (user));
75 if (MOD_RESULT == MOD_RES_DENY)
83 COMMAND_INIT(CommandUser)