Skip to content
Permalink
Browse files

FEATURE: invite_code is case-insensitive

Previously we required exact casing for invite code, this can cause a lot
of confusion. Relax the requirement.
  • Loading branch information
SamSaffron committed Mar 26, 2020
1 parent b2aa203 commit ecbccab1599d44903477fd9656e44286e8200829
Showing with 5 additions and 4 deletions.
  1. +1 −1 app/controllers/users_controller.rb
  2. +1 −1 config/locales/server.en.yml
  3. +3 −2 spec/requests/users_controller_spec.rb
@@ -425,7 +425,7 @@ def create
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

@@ -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"
@@ -618,15 +618,16 @@ def post_user(extra_params = {})

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")
expect(response.status).to eq(200)
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)

0 comments on commit ecbccab

Please sign in to comment.
You can’t perform that action at this time.