From b6b0791e3afa3ffce6479e7bfa4e84f66f983c50 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 21 Sep 2020 17:23:31 -0400 Subject: [PATCH] Require region codes are globally unique This is required for the ENX redirector, but we've also always made the assumption that these need to be globally unique. Note that this requires changing the column to citext (for case-insensitive matching) and to NULL out the default of '', since '' is a duplicate of ''. It also handles any existing duplicates by appending -N to them before applying the database-level unique constraint. --- .../realmadmin/_form_abuse_prevention.html | 4 +- cmd/server/assets/realmadmin/_form_codes.html | 1 + .../assets/realmadmin/_form_general.html | 5 +- .../assets/realmadmin/_form_security.html | 1 + cmd/server/assets/realmadmin/_form_sms.html | 2 +- pkg/controller/realmadmin/settings.go | 84 +++++++---------- pkg/database/database.go | 18 +++- pkg/database/migrations.go | 91 +++++++++++++++++++ pkg/database/realm.go | 31 +++++-- 9 files changed, 172 insertions(+), 65 deletions(-) diff --git a/cmd/server/assets/realmadmin/_form_abuse_prevention.html b/cmd/server/assets/realmadmin/_form_abuse_prevention.html index 08e32ab2d..db2f717b2 100644 --- a/cmd/server/assets/realmadmin/_form_abuse_prevention.html +++ b/cmd/server/assets/realmadmin/_form_abuse_prevention.html @@ -4,6 +4,7 @@
{{ .csrfField }} +

Abuse prevention uses the historical record of your realm's past @@ -18,9 +19,6 @@

- -