Handle current_user being both an admin and a moderator for building user list
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 14 Mar 2018 08:41:07 +0000 (16:41 +0800)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 14 Mar 2018 08:47:45 +0000 (16:47 +0800)
app/controllers/issues_controller.rb

index 10b626c..c2470dc 100644 (file)
@@ -11,12 +11,11 @@ class IssuesController < ApplicationController
 
     if current_user.moderator?
       @issue_types = %w[Note]
-      @users = User.joins(:roles).where(:user_roles => { :role => "moderator" })
     else
       @issue_types = %w[DiaryEntry DiaryComment User]
-      @users = User.joins(:roles).where(:user_roles => { :role => "administrator" })
     end
 
+    @users = User.joins(:roles).where(:user_roles => { :role => current_user.roles.map(&:role) }).distinct
     @issues = Issue.where(:assigned_role => current_user.roles.map(&:role))
 
     # If search