forked from External/greenlight
Replaced checkbox with dropdown (#552)
This commit is contained in:
parent
de1e75fbf8
commit
3e0238eb0c
|
@ -106,11 +106,6 @@ function changeBrandingImage(path) {
|
||||||
$.post(path, {url: url})
|
$.post(path, {url: url})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change whether or not user have to be signed in to join a room
|
|
||||||
function changeRoomAuthentication(checked, path) {
|
|
||||||
$.post(path, {authenticationRequired: checked})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filters by role
|
// Filters by role
|
||||||
function filterRole(role) {
|
function filterRole(role) {
|
||||||
search = new URL(location.href).searchParams.get('search')
|
search = new URL(location.href).searchParams.get('search')
|
||||||
|
|
|
@ -131,9 +131,9 @@ class AdminsController < ApplicationController
|
||||||
redirect_to admins_path
|
redirect_to admins_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /admins/meetingAuthentication
|
# POST /admins/room_authentication
|
||||||
def room_authentication
|
def room_authentication
|
||||||
@settings.update_value("Room Authentication", params[:authenticationRequired])
|
@settings.update_value("Room Authentication", params[:value])
|
||||||
redirect_to admins_path
|
redirect_to admins_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,31 +17,31 @@
|
||||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
module Themer
|
module Themer
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
# Lightens a color by 40%
|
# Lightens a color by 40%
|
||||||
def color_lighten(color)
|
def color_lighten(color)
|
||||||
# Uses the built in Sass Engine to lighten the color
|
# Uses the built in Sass Engine to lighten the color
|
||||||
|
|
||||||
dummy_scss = "h1 { color: $lighten; }"
|
dummy_scss = "h1 { color: $lighten; }"
|
||||||
compiled = Sass::Engine.new("$lighten:lighten(#{color}, 40%);" + dummy_scss, syntax: :scss).render
|
compiled = Sass::Engine.new("$lighten:lighten(#{color}, 40%);" + dummy_scss, syntax: :scss).render
|
||||||
|
|
||||||
string_locater = 'color: '
|
string_locater = 'color: '
|
||||||
color_start = compiled.index(string_locater) + string_locater.length
|
color_start = compiled.index(string_locater) + string_locater.length
|
||||||
|
|
||||||
compiled[color_start..color_start + 6]
|
compiled[color_start..color_start + 6]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Darkens a color by 10%
|
# Darkens a color by 10%
|
||||||
def color_darken(color)
|
def color_darken(color)
|
||||||
# Uses the built in Sass Engine to darken the color
|
# Uses the built in Sass Engine to darken the color
|
||||||
|
|
||||||
dummy_scss = "h1 { color: $darken; }"
|
dummy_scss = "h1 { color: $darken; }"
|
||||||
compiled = Sass::Engine.new("$darken:darken(#{color}, 10%);" + dummy_scss, syntax: :scss).render
|
compiled = Sass::Engine.new("$darken:darken(#{color}, 10%);" + dummy_scss, syntax: :scss).render
|
||||||
|
|
||||||
string_locater = 'color: '
|
string_locater = 'color: '
|
||||||
color_start = compiled.index(string_locater) + string_locater.length
|
color_start = compiled.index(string_locater) + string_locater.length
|
||||||
|
|
||||||
compiled[color_start..color_start + 6]
|
compiled[color_start..color_start + 6]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,8 +98,8 @@ class RoomsController < ApplicationController
|
||||||
|
|
||||||
# POST /:room_uid
|
# POST /:room_uid
|
||||||
def join
|
def join
|
||||||
# If this setting is turned on only authenticated users are allowed to join rooms
|
return redirect_to root_path,
|
||||||
room_authentication_required
|
flash: { alert: I18n.t("administrator.site_settings.authentication.user-info") } if auth_required
|
||||||
|
|
||||||
opts = default_meeting_options
|
opts = default_meeting_options
|
||||||
unless @room.owned_by?(current_user)
|
unless @room.owned_by?(current_user)
|
||||||
|
@ -275,11 +275,8 @@ class RoomsController < ApplicationController
|
||||||
redirect_to admins_path if current_user && current_user&.has_role?(:super_admin)
|
redirect_to admins_path if current_user && current_user&.has_role?(:super_admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
def room_authentication_required
|
def auth_required
|
||||||
if Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true" &&
|
Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true" &&
|
||||||
current_user.nil?
|
current_user.nil?
|
||||||
flash[:alert] = I18n.t("administrator.site_settings.authentication.user-info")
|
|
||||||
redirect_to signin_path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,8 +35,12 @@ module AdminsHelper
|
||||||
registration_method == Rails.configuration.registration_methods[:approval]
|
registration_method == Rails.configuration.registration_methods[:approval]
|
||||||
end
|
end
|
||||||
|
|
||||||
def room_authentication_required
|
def room_authentication_string
|
||||||
Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true"
|
if Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true"
|
||||||
|
I18n.t("administrator.site_settings.authentication.enabled")
|
||||||
|
else
|
||||||
|
I18n.t("administrator.site_settings.authentication.disabled")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def registration_method_string
|
def registration_method_string
|
||||||
|
|
|
@ -22,4 +22,9 @@ module RoomsHelper
|
||||||
def google_calendar_path
|
def google_calendar_path
|
||||||
"http://calendar.google.com/calendar/r/eventedit?text=#{@room.name}&location=#{request.base_url + request.fullpath}"
|
"http://calendar.google.com/calendar/r/eventedit?text=#{@room.name}&location=#{request.base_url + request.fullpath}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def room_authentication_required
|
||||||
|
Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true" &&
|
||||||
|
current_user.nil?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%= render 'shared/room_event' do %>
|
<%= render 'shared/room_event' do %>
|
||||||
<% if room_authentication_required && current_user.nil? %>
|
<% if room_authentication_required %>
|
||||||
<h2><%= t("administrator.site_settings.authentication.user-info") %></h2>
|
<h2><%= t("administrator.site_settings.authentication.user-info") %></h2>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= form_for room_path(@room), method: :post do |f| %>
|
<%= form_for room_path(@room), method: :post do |f| %>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="mb-7 form-group">
|
<div class="mb-6 form-group">
|
||||||
<label class="form-label"><%= t("administrator.site_settings.branding.title") %></label>
|
<label class="form-label"><%= t("administrator.site_settings.branding.title") %></label>
|
||||||
<label class="form-label text-muted"><%= t("administrator.site_settings.branding.info") %></label>
|
<label class="form-label text-muted"><%= t("administrator.site_settings.branding.info") %></label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
@ -30,20 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="mb-7 form-group">
|
<div class="mb-6 form-group">
|
||||||
<label class="form-label"><%= t("administrator.site_settings.authentication.title") %></label>
|
|
||||||
<div class="row gutters-xs">
|
|
||||||
<label class="custom-control custom-checkbox ml-1">
|
|
||||||
<%= check_box_tag "room_authentication", '', room_authentication_required, class: 'custom-control-input', onchange: "changeRoomAuthentication(this.checked, '#{admin_room_authentication_path}')"%>
|
|
||||||
<span class="custom-control-label text-muted authentication-required"><%= t("administrator.site_settings.authentication.info") %></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="mb-7 form-group">
|
|
||||||
<label class="form-label"><%= t("administrator.site_settings.color.title") %></label>
|
<label class="form-label"><%= t("administrator.site_settings.color.title") %></label>
|
||||||
<label class="form-label text-muted"><%= t("administrator.site_settings.color.info") %></label>
|
<label class="form-label text-muted"><%= t("administrator.site_settings.color.info") %></label>
|
||||||
<div class="color-inputs">
|
<div class="color-inputs">
|
||||||
|
@ -68,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="mb-6 col-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label"><%= t("administrator.site_settings.registration.title") %></label>
|
<label class="form-label"><%= t("administrator.site_settings.registration.title") %></label>
|
||||||
<label class="form-label text-muted"><%= t("administrator.site_settings.registration.info") %></label>
|
<label class="form-label text-muted"><%= t("administrator.site_settings.registration.info") %></label>
|
||||||
|
@ -91,4 +78,25 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label"><%= t("administrator.site_settings.authentication.title") %></label>
|
||||||
|
<label class="form-label text-muted"><%= t("administrator.site_settings.authentication.info") %></label>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-primary dropdown-toggle" type="button" id="room-auth" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<%= room_authentication_string %>
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="room-auth">
|
||||||
|
<%= button_to admin_room_authentication_path(value: "true"), class: "dropdown-item" do %>
|
||||||
|
<%= t("administrator.site_settings.authentication.enabled") %>
|
||||||
|
<% end %>
|
||||||
|
<%= button_to admin_room_authentication_path(value: "false"), class: "dropdown-item" do %>
|
||||||
|
<%= t("administrator.site_settings.authentication.disabled") %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,6 +24,8 @@ en:
|
||||||
administrator:
|
administrator:
|
||||||
site_settings:
|
site_settings:
|
||||||
authentication:
|
authentication:
|
||||||
|
disabled: Disabled
|
||||||
|
enabled: Enabled
|
||||||
info: Only allow authenticated users to join a room
|
info: Only allow authenticated users to join a room
|
||||||
title: Require Authentication for Rooms
|
title: Require Authentication for Rooms
|
||||||
user-info: You must sign in to Greenlight to join this room
|
user-info: You must sign in to Greenlight to join this room
|
||||||
|
|
|
@ -285,13 +285,12 @@ describe AdminsController, type: :controller do
|
||||||
allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
|
allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
|
||||||
|
|
||||||
@request.session[:user_id] = @admin.id
|
@request.session[:user_id] = @admin.id
|
||||||
checked = true
|
|
||||||
|
|
||||||
post :room_authentication, params: { authenticationRequired: checked }
|
post :room_authentication, params: { value: "true" }
|
||||||
|
|
||||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Authentication")
|
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Authentication")
|
||||||
|
|
||||||
expect(feature[:value]).to eq(checked.to_s)
|
expect(feature[:value]).to eq("true")
|
||||||
expect(response).to redirect_to(admins_path)
|
expect(response).to redirect_to(admins_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -212,7 +212,8 @@ describe RoomsController, type: :controller do
|
||||||
|
|
||||||
post :join, params: { room_uid: @room }
|
post :join, params: { room_uid: @room }
|
||||||
|
|
||||||
expect(response).to redirect_to(signin_path)
|
expect(flash[:alert]).to be_present
|
||||||
|
expect(response).to redirect_to(root_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue