AttorneyOnline / tsuserver3

An Attorney Online server.
GNU Affero General Public License v3.0
25 stars 51 forks source link

Any user, once banned by IPID once, cannot be banned again #171

Open Lernos opened 3 years ago

Lernos commented 3 years ago

Once an IPID ban has been logged into the database, the same IPID can never be banned again in the future, sending the following error into OOC: "Error inserting ban: UNIQUE constraint failed: ip_bans.ipid (the IPID may not exist)". As suggested by sD, this is fixable by changing ipid data type in ip_bans from TEXT PRIMARY KEY to INTEGER NOT NULL, but needs to be implemented in the code at database creation. Also, HDID bans haven't been tested.

Lernos commented 3 years ago

Here's the actual solution. In migrations/v4.sql we need to replace

CREATE TABLE ip_bans_new( ipid TEXT PRIMARY KEY,

with

CREATE TABLE ip_bans_new( ipid INTEGER NOT NULL,

Since I have little experience with SQL, I'm not sure whether INTEGER NOT NULL or INTEGER PRIMARY KEY would be more applicable here, but the former, as I am inclined to repeat, is stonedDiscord's first glance intended solution.

oldmud0 commented 3 years ago

Yeah, IPID shouldn't have been the PK. Smh (at myself)