aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-06-06 20:22:19 +0300
committerRblSb <msrblsb@gmail.com>2021-06-06 20:22:56 +0300
commit13127249ddd1f61f8ed6b75803b0de1f4d25f96e (patch)
treebfb359bbdf1ab7f4b7c470e54fd4e210dddb7448 /src/server/Main.hx
parent03f81af4259c6b58dbef4dfda4683af8a6980759 (diff)
Less silly logins
And Haxe update
Diffstat (limited to 'src/server/Main.hx')
-rw-r--r--src/server/Main.hx18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx
index 565daab..d93c2e5 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -390,22 +390,22 @@ class Main {
case UpdateClients:
sendClientList();
case Login:
- final name = data.login.clientName;
- if (badNickName(name) || name.length > config.maxLoginLength
- || clients.getByName(name) != null) {
+ final name = data.login.clientName.trim();
+ final lcName = name.toLowerCase();
+ if (badNickName(lcName)) {
serverMessage(client, "usernameError");
send(client, {type: LoginError});
return;
}
final hash = data.login.passHash;
if (hash == null) {
- if (userList.admins.exists(a -> a.name == name)) {
+ if (userList.admins.exists(a -> a.name.toLowerCase() == lcName)) {
send(client, {type: PasswordRequest});
return;
}
} else {
if (userList.admins.exists(
- a -> a.name == name && a.hash == hash
+ a -> a.name.toLowerCase() == lcName && a.hash == hash
)) client.isAdmin = true;
else {
serverMessage(client, "passwordMatchError");
@@ -733,11 +733,15 @@ class Main {
return state;
}
- final htmlChars = ~/[&^<>'"]/;
+ final matchHtmlChars = ~/[&^<>'"]/;
+ final matchGuestName = ~/guest [0-9]+/;
public function badNickName(name:String):Bool {
+ if (name.length > config.maxLoginLength) return true;
if (name.length == 0) return true;
- if (htmlChars.match(name)) return true;
+ if (matchHtmlChars.match(name)) return true;
+ if (matchGuestName.match(name)) return true;
+ if (clients.exists(i -> i.name.toLowerCase() == name)) return true;
return false;
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage