From c4d1135bf4d321dbed6ab3a94f87029e87f22a5d Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 8 Dec 2024 10:58:12 +0800 Subject: USER: Don't allow reregistration --- cmd_user.go | 10 +++++++--- numerics.go | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd_user.go b/cmd_user.go index 99d9027..3db56c7 100644 --- a/cmd_user.go +++ b/cmd_user.go @@ -13,10 +13,14 @@ func handleClientUser(msg RMsg, client *Client) bool { client.Send(MakeMsg(self, ERR_NEEDMOREPARAMS, "USER", "Not enough parameters")) return true } - client.Ident = "~" + msg.Params[0] - client.Gecos = msg.Params[3] - if client.State == ClientStatePreRegistration { + switch (client.State) { + case ClientStatePreRegistration: + client.Ident = "~" + msg.Params[0] + client.Gecos = msg.Params[3] client.checkRegistration() + case ClientStateRegistered: + client.Send(MakeMsg(self, ERR_ALREADYREGISTERED, client.Nick, "You may not reregister")) + case ClientStateRemote: } return true } diff --git a/numerics.go b/numerics.go index c8a351b..8877306 100644 --- a/numerics.go +++ b/numerics.go @@ -9,4 +9,5 @@ const ( ERR_INPUTTOOLONG = "417" ERR_NEEDMOREPARAMS = "461" ERR_NICKNAMEINUSE = "433" + ERR_ALREADYREGISTERED = "462" ) -- cgit v1.2.3