2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
8 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
11 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "core_user.h"
33 ERR_INVALIDUSERNAME = 468
36 CommandUser::CommandUser(Module* parent)
37 : SplitCommand(parent, "USER", 4, 4)
39 allow_empty_last_param = false;
40 works_before_reg = true;
42 syntax = "<username> <unused> <unused> :<realname>";
45 CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters)
47 /* A user may only send the USER command once */
48 if (!(user->registered & REG_USER))
50 if (!ServerInstance->IsIdent(parameters[0]))
52 user->WriteNumeric(ERR_INVALIDUSERNAME, name, "Your username is not valid");
57 user->ChangeIdent(parameters[0]);
58 user->ChangeRealName(parameters[3]);
59 user->registered = (user->registered | REG_USER);
64 user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
65 user->CommandFloodPenalty += 1000;
69 /* parameters 2 and 3 are local and remote hosts, and are ignored */
70 return CheckRegister(user);
73 CmdResult CommandUser::CheckRegister(LocalUser* user)
75 // If the user is registered, return CMD_SUCCESS/CMD_FAILURE depending on what modules say, otherwise just
76 // return CMD_SUCCESS without doing anything, knowing the other handler will call us again
77 if (user->registered == REG_NICKUSER)
80 FIRST_MOD_RESULT(OnUserRegister, MOD_RESULT, (user));
81 if (MOD_RESULT == MOD_RES_DENY)