@@ -103,18 +103,6 @@ final class User
103103
104104 void authenticate (string username, string password)
105105 {
106- const user_exists = server.db.user_exists(username);
107-
108- if (! user_exists && server.db.server_private_mode) {
109- reject_login(LoginRejectionReason.server_private);
110- return ;
111- }
112-
113- if (server.num_connected_users >= server.db.server_max_users) {
114- reject_login(LoginRejectionReason.server_full);
115- return ;
116- }
117-
118106 const invalid_name_reason = check_username(username);
119107 if (invalid_name_reason ! is null ) {
120108 reject_login(
@@ -129,6 +117,28 @@ final class User
129117 return ;
130118 }
131119
120+ const banned_until = server.db.user_banned_until(username);
121+ if (banned_until > Clock .currTime)
122+ // The official server doesn't send a response when a user
123+ // is banned. We also ban users temporarily when kicking
124+ // them, and simply closing the connection after some time
125+ // allows the client to automatically reconnect to the
126+ // server.
127+ return ;
128+
129+ if (banned_until > SysTime()) server.db.unban_user(username);
130+
131+ const user_exists = server.db.user_exists(username);
132+ if (! user_exists && server.db.server_private_mode) {
133+ reject_login(LoginRejectionReason.server_private);
134+ return ;
135+ }
136+
137+ if (server.num_connected_users >= server.db.server_max_users) {
138+ reject_login(LoginRejectionReason.server_full);
139+ return ;
140+ }
141+
132142 if (! user_exists) {
133143 hashing_password = true ;
134144 const salt = create_salt();
0 commit comments