Skip to content

A platform for community discussion. Free, open, simple.

FIX: Ignore title parameter during public signup (#41381)

Gabriel Grubba4dbaafd291f7
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index dc932572857..8011ae2f44e 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -700,7 +700,7 @@ class UsersController < ApplicationController
if current_user&.admin? && is_api?
user_params.except(:timezone)
else
- user_params.except(:timezone, :primary_group_id, :flair_group_id)
+ user_params.except(:timezone, :title, :primary_group_id, :flair_group_id)
end
user = User.where(staged: true).with_email(new_user_params[:email].strip.downcase).first
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 972d76c1a00..51ba5382542 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -906,18 +906,26 @@ RSpec.describe UsersController do
end
end
- context "when signup params include group assignments" do
+ context "when signup params include protected profile attributes" do
fab!(:whisperers_group, :group)
let(:created_user) { User.find(response.parsed_body["user_id"]) }
before { SiteSetting.whispers_allowed_groups = whisperers_group.id.to_s }
- it "ignores primary_group_id and flair_group_id on unauthenticated signup" do
- post_user(primary_group_id: whisperers_group.id, flair_group_id: whisperers_group.id)
+ it "ignores protected profile attributes on unauthenticated signup" do
+ post_user(
+ title: "Moderator",
+ primary_group_id: whisperers_group.id,
+ flair_group_id: whisperers_group.id,
+ )
expect(response).to have_http_status(:ok)
- expect(created_user).to have_attributes(primary_group_id: nil, flair_group_id: nil)
+ expect(created_user).to have_attributes(
+ title: nil,
+ primary_group_id: nil,
+ flair_group_id: nil,
+ )
expect(created_user).not_to be_a_whisperer
end
end