FEATURE: invite_code is case-insensitive

FEATURE: invite_code is case-insensitive

Previously we required exact casing for invite code, this can cause a lot of confusion. Relax the requirement.

diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index da9ba48..79bee42 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -425,7 +425,7 @@ class UsersController < ApplicationController
       return fail_with("login.email_too_long")
     end
 
-    if SiteSetting.require_invite_code && SiteSetting.invite_code != params[:invite_code]
+    if SiteSetting.require_invite_code && SiteSetting.invite_code.strip.downcase != params[:invite_code].strip.downcase
       return fail_with("login.wrong_invite_code")
     end
 
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 110d398..b1fd878 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1529,7 +1529,7 @@ en:
     markdown_typographer_quotation_marks: "List of double and single quotes replacement pairs"
     post_undo_action_window_mins: "Number of minutes users are allowed to undo recent actions on a post (like, flag, etc)."
     must_approve_users: "Staff must approve all new user accounts before they are allowed to access the site."
-    invite_code: "User must type this code to be allowed account registration, ignored when empty"
+    invite_code: "User must type this code to be allowed account registration, ignored when empty (case-insensitive)"
     approve_suspect_users: "Add suspicious users to the review queue. Suspicious users have entered a bio/website but have no reading activity."
     pending_users_reminder_delay: "Notify moderators if new users have been waiting for approval for longer than this many hours. Set to -1 to disable notifications."
     maximum_session_age: "User will remain logged in for n hours since last visit"
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 57a936a..95d675f 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -618,7 +618,7 @@ describe UsersController do
 
       it 'requires invite code when specified' do
         expect(SiteSetting.require_invite_code).to eq(false)
-        SiteSetting.invite_code = "abc"
+        SiteSetting.invite_code = "abc def"
         expect(SiteSetting.require_invite_code).to eq(true)
 
         post_user(invite_code: "abcd")
@@ -626,7 +626,8 @@ describe UsersController do
         json = JSON.parse(response.body)
         expect(json["success"]).to eq(false)
 
-        post_user(invite_code: "abc")
+        # case insensitive and stripped of leading/ending spaces
+        post_user(invite_code: " AbC deF ")
         expect(response.status).to eq(200)
         json = JSON.parse(response.body)
         expect(json["success"]).to eq(true)

GitHub sha: ecbccab1