Skip to content

Commit

Permalink
add guest landing page when guest access disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-arts committed Jul 13, 2017
1 parent ec16f51 commit ab5c56c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 19 deletions.
Binary file added app/assets/images/signin-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions app/controllers/landing_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ class LandingController < ApplicationController
include BbbApi

def index
redirect_to user_login_path if Rails.configuration.disable_guest_access
# If guest access is disabled, redirect the user to the guest landing and force login.
redirect_to guest_path if Rails.configuration.disable_guest_access
end

def resource
if Rails.configuration.disable_guest_access && params[:resource] == 'meetings'
redirect_to user_login_path
redirect_to guest_path
else
if params[:id].size > meeting_name_limit
redirect_to root_url, flash: {danger: t('meeting_name_long')}
Expand All @@ -38,6 +39,11 @@ def resource
end
end
end

def guest
# If someone tries to aceess the guest landing when guest access is enabled, just send them to root.
redirect_to root_url unless Rails.configuration.disable_guest_access
end

def send_meetings_data
render json: {active: bbb.get_meetings, waiting: WaitingList.waiting}
Expand Down
44 changes: 44 additions & 0 deletions app/views/landing/guest.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<%
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
# Copyright (c) 2016 BigBlueButton Inc. and by respective authors (see below).
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>

<div class="page-wrapper meetings">
<div class="container-fluid">

<div class="center-panel-wrapper">
<%= render layout: 'shared/center_panel' do %>
<h1 class='text-center'><%= t('welcome_to_greenlight') %></h1>
<br>
<%= link_to user_login_path, class: "signin-link" do %>
<div class="signin-button center-block">
<div class="signin-icon-wrapper">
<%= image_tag("signin-icon.png", alt: "L", class: "signin-icon") %>
</div>
<div class="signin-text-wrapper text-center">
<span class="signin-text"><%= t('login_greenlight') %></span>
</div>
</div>
<% end %>
<br>
<p class='text-center' style='font-size: 13px;'> <%= t('guest_sentence_one_html', bbb_link: link_to('BigBlueButton',
'http://bigbluebutton.org/', target: "_blank")) %><br><%= t('guest_sentence_two') %></p>
<% end %>
</div>

<div class="text-center" style="padding-top:20px;">
<iframe width="560" height="315" src="https://www.youtube.com/embed/yGX3JCv7OVM" frameborder="0" allowfullscreen></iframe>
</div>

</div>
</div>
4 changes: 4 additions & 0 deletions config/locales/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ en-US:
error: An error occured
error_title: An error has occured
footer_html: Powered by %{bbb_link}
guest_sentence_one_html: GreenLight lets you create and manage %{bbb_link} meetings and recordings.
guest_sentence_two: To learn more about how GreenLight works, check out the video below!
help: Help
hi_all: Hi Everyone
home_page: Home page
Expand All @@ -107,6 +109,7 @@ en-US:
logged_in_description_html: You are logged in as %{link}
login: login
login_description: Want to record a meeting?
login_greenlight: Login to GreenLight
logout: logout
meeting: Meeting
meeting_invite:
Expand Down Expand Up @@ -184,6 +187,7 @@ en-US:
wait_for_mod_explanation: You will automatically join when the meeting starts
watch: Watch
'yes': 'Yes'
welcome_to_greenlight: Welcome to GreenLight!
youtube_description: This recording was recorded with BigBlueButton. For more information check out %{url}.
youtube_footer: this will upload all webcam and audio data
youtube_privacy_options:
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
get '/(:room_id)/:id', to: 'landing#resource', as: :meeting_room, defaults: {room_id: nil}, :constraints => {:id => disallow_slash, :room_id => disallow_slash}
end

get '/guest', to: 'landing#guest', as: :guest
get '/preferences', to: 'landing#preferences', as: :preferences

root to: 'landing#index', :resource => 'meetings'
Expand Down
36 changes: 19 additions & 17 deletions test/controllers/landing_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,33 @@

class LandingControllerTest < ActionController::TestCase

# Should redirect to login url if guest access is disabled.
def assert_login_or_success
if Rails.configuration.disable_guest_access
assert_redirected_to user_login_path
else
assert_response :success
end
end

setup do
@meeting_id = 'test_id'
@user = users :user1
end

test "should get index" do
Rails.configuration.disable_guest_access = false
get :index, params: {resource: 'meetings'}
assert_response :success
end

test "should redirect to guest from index" do
Rails.configuration.disable_guest_access = true
get :index, params: {resource: 'meetings'}
assert_login_or_success
assert_redirected_to guest_path
end

test "should get meeting" do
Rails.configuration.disable_guest_access = false
get :resource, params: { id: @meeting_id, resource: 'meetings' }
assert_login_or_success
assert_response :success
end

test "should redirect to guest from meeting" do
Rails.configuration.disable_guest_access = true
get :index, params: {resource: 'meetings'}
assert_redirected_to guest_path
end

test "should get room" do
Expand Down Expand Up @@ -68,14 +73,11 @@ def assert_login_or_success
end

test "should fallback to en-US locale if locale is en" do
Rails.configuration.disable_guest_access = false
request.headers["Accept-Language"] = 'en'
get :index, params: {resource: 'meetings'}
if Rails.configuration.disable_guest_access
assert_redirected_to user_login_path
else
assert_response :success
assert css_select('html').attribute('lang').value, 'en'
end
assert_response :success
assert css_select('html').attribute('lang').value, 'en'
end

end

0 comments on commit ab5c56c

Please sign in to comment.