forked from External/greenlight
GRN2-128: Fixed issue with manage rooms permissions (#929)
* Fixed issue with manage rooms permissions * Improved server rooms efficiency
This commit is contained in:
parent
967130e57c
commit
397b4b742f
|
@ -41,7 +41,7 @@ class AdminsController < ApplicationController
|
||||||
@role = params[:role] ? Role.find_by(name: params[:role], provider: @user_domain) : nil
|
@role = params[:role] ? Role.find_by(name: params[:role], provider: @user_domain) : nil
|
||||||
@tab = params[:tab] || "active"
|
@tab = params[:tab] || "active"
|
||||||
|
|
||||||
@pagy, @users = pagy(user_list)
|
@pagy, @users = pagy(manage_users_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /admins/site_settings
|
# GET /admins/site_settings
|
||||||
|
@ -64,11 +64,11 @@ class AdminsController < ApplicationController
|
||||||
@order_column = params[:column] && params[:direction] != "none" ? params[:column] : "created_at"
|
@order_column = params[:column] && params[:direction] != "none" ? params[:column] : "created_at"
|
||||||
@order_direction = params[:direction] && params[:direction] != "none" ? params[:direction] : "DESC"
|
@order_direction = params[:direction] && params[:direction] != "none" ? params[:direction] : "DESC"
|
||||||
|
|
||||||
server_rooms = server_rooms_list
|
@running_room_bbb_ids = all_running_meetings[:meetings].pluck(:meetingID)
|
||||||
|
|
||||||
@user_list = shared_user_list if shared_access_allowed
|
@user_list = shared_user_list if shared_access_allowed
|
||||||
|
|
||||||
@pagy, @rooms = pagy_array(server_rooms)
|
@pagy, @rooms = pagy_array(server_rooms_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
# MANAGE USERS
|
# MANAGE USERS
|
||||||
|
@ -254,37 +254,6 @@ class AdminsController < ApplicationController
|
||||||
flash: { alert: I18n.t("administrator.flash.unauthorized") } unless current_user.admin_of?(@user)
|
flash: { alert: I18n.t("administrator.flash.unauthorized") } unless current_user.admin_of?(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gets the list of users based on your configuration
|
|
||||||
def user_list
|
|
||||||
current_role = @role
|
|
||||||
|
|
||||||
initial_user = case @tab
|
|
||||||
when "active"
|
|
||||||
User.without_role(:pending).without_role(:denied)
|
|
||||||
when "deleted"
|
|
||||||
User.deleted
|
|
||||||
else
|
|
||||||
User
|
|
||||||
end
|
|
||||||
|
|
||||||
current_role = Role.find_by(name: @tab, provider: @user_domain) if @tab == "pending" || @tab == "denied"
|
|
||||||
|
|
||||||
initial_list = if current_user.has_role? :super_admin
|
|
||||||
initial_user.where.not(id: current_user.id)
|
|
||||||
else
|
|
||||||
initial_user.without_role(:super_admin).where.not(id: current_user.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
if Rails.configuration.loadbalanced_configuration
|
|
||||||
initial_list.where(provider: @user_domain)
|
|
||||||
.admins_search(@search, current_role)
|
|
||||||
.admins_order(@order_column, @order_direction)
|
|
||||||
else
|
|
||||||
initial_list.admins_search(@search, current_role)
|
|
||||||
.admins_order(@order_column, @order_direction)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Creates the invite if it doesn't exist, or updates the updated_at time if it does
|
# Creates the invite if it doesn't exist, or updates the updated_at time if it does
|
||||||
def create_or_update_invite(email)
|
def create_or_update_invite(email)
|
||||||
invite = Invitation.find_by(email: email, provider: @user_domain)
|
invite = Invitation.find_by(email: email, provider: @user_domain)
|
||||||
|
@ -300,10 +269,4 @@ class AdminsController < ApplicationController
|
||||||
|
|
||||||
invite
|
invite
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the room status to display in the Server Rooms table
|
|
||||||
def room_is_running(id)
|
|
||||||
room_running?(id)
|
|
||||||
end
|
|
||||||
helper_method :room_is_running
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,11 @@ module BbbServer
|
||||||
bbb_server.is_meeting_running?(bbb_id)
|
bbb_server.is_meeting_running?(bbb_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a list of all running meetings
|
||||||
|
def all_running_meetings
|
||||||
|
bbb_server.get_meetings
|
||||||
|
end
|
||||||
|
|
||||||
def get_recordings(meeting_id)
|
def get_recordings(meeting_id)
|
||||||
bbb_server.get_recordings(meetingID: meeting_id)
|
bbb_server.get_recordings(meetingID: meeting_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,37 @@
|
||||||
module Populator
|
module Populator
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
# Returns a list of users that are in the same context of the current user
|
||||||
|
def manage_users_list
|
||||||
|
current_role = @role
|
||||||
|
|
||||||
|
initial_user = case @tab
|
||||||
|
when "active"
|
||||||
|
User.without_role(:pending).without_role(:denied)
|
||||||
|
when "deleted"
|
||||||
|
User.deleted
|
||||||
|
else
|
||||||
|
User
|
||||||
|
end
|
||||||
|
|
||||||
|
current_role = Role.find_by(name: @tab, provider: @user_domain) if @tab == "pending" || @tab == "denied"
|
||||||
|
|
||||||
|
initial_list = if current_user.has_role? :super_admin
|
||||||
|
initial_user.where.not(id: current_user.id)
|
||||||
|
else
|
||||||
|
initial_user.without_role(:super_admin).where.not(id: current_user.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
if Rails.configuration.loadbalanced_configuration
|
||||||
|
initial_list.where(provider: @user_domain)
|
||||||
|
.admins_search(@search, current_role)
|
||||||
|
.admins_order(@order_column, @order_direction)
|
||||||
|
else
|
||||||
|
initial_list.admins_search(@search, current_role)
|
||||||
|
.admins_order(@order_column, @order_direction)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns a list of rooms that are in the same context of the current user
|
# Returns a list of rooms that are in the same context of the current user
|
||||||
def server_rooms_list
|
def server_rooms_list
|
||||||
if Rails.configuration.loadbalanced_configuration
|
if Rails.configuration.loadbalanced_configuration
|
||||||
|
|
|
@ -71,4 +71,9 @@ module AdminsHelper
|
||||||
def edit_disabled
|
def edit_disabled
|
||||||
@edit_disabled ||= @selected_role.priority <= current_user.highest_priority_role.priority
|
@edit_disabled ||= @selected_role.priority <= current_user.highest_priority_role.priority
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get the room status to display in the Server Rooms table
|
||||||
|
def room_is_running(id)
|
||||||
|
@running_room_bbb_ids.include?(id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,14 +35,15 @@ class Role < ApplicationRecord
|
||||||
.update_all_role_permissions(can_create_rooms: true)
|
.update_all_role_permissions(can_create_rooms: true)
|
||||||
Role.create(name: "admin", provider: provider, priority: 0, colour: "#f1c40f")
|
Role.create(name: "admin", provider: provider, priority: 0, colour: "#f1c40f")
|
||||||
.update_all_role_permissions(can_create_rooms: true, send_promoted_email: true,
|
.update_all_role_permissions(can_create_rooms: true, send_promoted_email: true,
|
||||||
send_demoted_email: true, can_edit_site_settings: true,
|
send_demoted_email: true, can_edit_site_settings: true, can_manage_rooms_recordings: true,
|
||||||
can_edit_roles: true, can_manage_users: true)
|
can_edit_roles: true, can_manage_users: true)
|
||||||
Role.create(name: "pending", provider: provider, priority: -1, colour: "#17a2b8").update_all_role_permissions
|
Role.create(name: "pending", provider: provider, priority: -1, colour: "#17a2b8").update_all_role_permissions
|
||||||
Role.create(name: "denied", provider: provider, priority: -1, colour: "#343a40").update_all_role_permissions
|
Role.create(name: "denied", provider: provider, priority: -1, colour: "#343a40").update_all_role_permissions
|
||||||
Role.create(name: "super_admin", provider: provider, priority: -2, colour: "#cd201f")
|
Role.create(name: "super_admin", provider: provider, priority: -2, colour: "#cd201f")
|
||||||
.update_all_role_permissions(can_create_rooms: true,
|
.update_all_role_permissions(can_create_rooms: true,
|
||||||
send_promoted_email: true, send_demoted_email: true, can_edit_site_settings: true,
|
send_promoted_email: true, send_demoted_email: true, can_edit_site_settings: true,
|
||||||
can_edit_roles: true, can_manage_users: true, can_appear_in_share_list: true)
|
can_edit_roles: true, can_manage_users: true, can_manage_rooms_recordings: true,
|
||||||
|
can_appear_in_share_list: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_new_role(role_name, provider)
|
def self.create_new_role(role_name, provider)
|
||||||
|
@ -74,6 +75,9 @@ class Role < ApplicationRecord
|
||||||
|
|
||||||
# Updates the value of the permission and enables it
|
# Updates the value of the permission and enables it
|
||||||
def update_permission(name, value)
|
def update_permission(name, value)
|
||||||
|
# Dont update if it is not explicitly set to a value
|
||||||
|
return unless value.present?
|
||||||
|
|
||||||
permission = role_permissions.find_or_create_by!(name: name)
|
permission = role_permissions.find_or_create_by!(name: name)
|
||||||
|
|
||||||
permission.update_attributes(value: value, enabled: true)
|
permission.update_attributes(value: value, enabled: true)
|
||||||
|
|
|
@ -95,6 +95,7 @@ en:
|
||||||
title: Server Recordings
|
title: Server Recordings
|
||||||
no_recordings: This server has no recordings.
|
no_recordings: This server has no recordings.
|
||||||
roles:
|
roles:
|
||||||
|
appear_in_share_list: Include users with this role in the dropdown for sharing rooms
|
||||||
can_create_rooms: Can create rooms
|
can_create_rooms: Can create rooms
|
||||||
delete: Delete the role
|
delete: Delete the role
|
||||||
invalid_create: There was a problem creating a new role. Please check the role values and try again
|
invalid_create: There was a problem creating a new role. Please check the role values and try again
|
||||||
|
|
Loading…
Reference in New Issue