From 464dd4266bdc433805010b5dca428f4cb75c2a81 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 31 Jul 2026 15:55:43 +0200 Subject: Group user accounts by role Replaces the two-way admin/user split with four groups ordered by capability: administration, Redaktion, editors, alumni. alumni takes precedence over capability in role_group, so a retired admin appears at the bottom rather than the top. Forms now offer the three roles as checkboxes rather than a single admin checkbox, with a trailing hidden blank so an empty set can be posted, and user_params permits roles only for admins. Three create buttons prefill the common combinations. --- lib/authenticated_system.rb | 7 ++++++- lib/tasks/development_init.rake | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/authenticated_system.rb b/lib/authenticated_system.rb index 2ec15a77..4e70c28d 100644 --- a/lib/authenticated_system.rb +++ b/lib/authenticated_system.rb @@ -102,7 +102,12 @@ module AuthenticatedSystem def login_from_session return unless session[:user_id] if session[:logged_in_at].to_i > SESSION_MAX_AGE.ago.to_i - self.current_user = User.find_by(:id => session[:user_id]) + user = User.find_by(:id => session[:user_id]) + if user.nil? || user.alumni? + session[:user_id] = nil + else + self.current_user = user + end else session[:user_id] = nil end diff --git a/lib/tasks/development_init.rake b/lib/tasks/development_init.rake index 94f323c3..91797d9b 100644 --- a/lib/tasks/development_init.rake +++ b/lib/tasks/development_init.rake @@ -19,7 +19,7 @@ namespace :cccms do :email => 'admin@cccms.de', :password => 'foobar', :password_confirmation => 'foobar', - :admin => true + :roles => ["admin", "redaktion"] ) end -- cgit v1.3