]> source.dussan.org Git - redmine.git/commitdiff
Set builtin and new roles' user visibility to members_of_visible_projects (#38853).
authorMarius Balteanu <marius.balteanu@zitec.com>
Sun, 3 Nov 2024 18:48:58 +0000 (18:48 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sun, 3 Nov 2024 18:48:58 +0000 (18:48 +0000)
Patch by Holger Just (user:hjust).

git-svn-id: https://svn.redmine.org/redmine/trunk@23198 e93f8b46-1217-0410-a6f0-8f06a7374b81

db/migrate/20241103184550_change_builtin_roles_user_visibility.rb [new file with mode: 0644]

diff --git a/db/migrate/20241103184550_change_builtin_roles_user_visibility.rb b/db/migrate/20241103184550_change_builtin_roles_user_visibility.rb
new file mode 100644 (file)
index 0000000..4e8b0f7
--- /dev/null
@@ -0,0 +1,14 @@
+class ChangeBuiltinRolesUserVisibility < ActiveRecord::Migration[7.2]
+  def up
+    # Default to members_of_visible_projects for all newly created roles
+    change_column_default :roles, :users_visibility, 'members_of_visible_projects'
+
+    # Set the users visibility of the builtin roles (Anonymous and Non-Member)
+    # to members_of_visible_projects as a saf(er) default.
+    Role.where.not(builtin: 0).update_all(users_visibility: 'members_of_visible_projects')
+  end
+
+  def down
+    change_column_default :roles, :users_visibility, 'all'
+  end
+end