forked from External/greenlight
add ability to configure terms and conditions
This commit is contained in:
parent
2dc033ee20
commit
c16197670b
|
@ -89,3 +89,9 @@ a {
|
||||||
.force-text-normal {
|
.force-text-normal {
|
||||||
color: #495057;
|
color: #495057;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.terms {
|
||||||
|
overflow: scroll;
|
||||||
|
height: 55vh;
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ApplicationController < ActionController::Base
|
||||||
meeting_logout_url: request.base_url + logout_room_path(@room),
|
meeting_logout_url: request.base_url + logout_room_path(@room),
|
||||||
meeting_recorded: true,
|
meeting_recorded: true,
|
||||||
moderator_message: "To invite someone to the meeting, send them this link:\n\n
|
moderator_message: "To invite someone to the meeting, send them this link:\n\n
|
||||||
#{request.base_url + Rails.configuration.relative_url_root + room_path(@room)}"
|
#{request.base_url + relative_root + room_path(@room)}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,6 @@ class MainController < ApplicationController
|
||||||
|
|
||||||
def redirect_to_room
|
def redirect_to_room
|
||||||
# If the user is logged in already, move them along to their room.
|
# If the user is logged in already, move them along to their room.
|
||||||
redirect_to room_path(current_user.room.uid) if current_user
|
redirect_to room_path(current_user.room) if current_user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class RoomsController < ApplicationController
|
class RoomsController < ApplicationController
|
||||||
|
|
||||||
|
before_action :validate_accepted_terms, unless: -> { !Rails.configuration.terms }
|
||||||
before_action :find_room, except: :create
|
before_action :find_room, except: :create
|
||||||
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
|
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
|
||||||
|
|
||||||
|
@ -159,4 +160,8 @@ class RoomsController < ApplicationController
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_accepted_terms
|
||||||
|
redirect_to terms_path unless current_user.accepted_terms
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,6 +74,16 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET /u/terms
|
||||||
|
def terms
|
||||||
|
redirect_to root_path unless current_user
|
||||||
|
|
||||||
|
if params[:accept] == "true"
|
||||||
|
current_user.update_attribute(accepted_terms: true)
|
||||||
|
redirect_to current_user.main_room
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_user
|
def find_user
|
||||||
|
|
|
@ -3,7 +3,13 @@ module SessionsHelper
|
||||||
# Logs a user into GreenLight.
|
# Logs a user into GreenLight.
|
||||||
def login(user)
|
def login(user)
|
||||||
session[:user_id] = user.id
|
session[:user_id] = user.id
|
||||||
redirect_to user.main_room
|
|
||||||
|
# If there are not terms, or the user has accepted them, go to their room.
|
||||||
|
if !Rails.configuration.terms || user.accepted_terms then
|
||||||
|
redirect_to user.main_room
|
||||||
|
else
|
||||||
|
redirect_to terms_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logs current user out of GreenLight.
|
# Logs current user out of GreenLight.
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="col-md-8 offset-2">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">Terms and Conditions</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="terms">
|
||||||
|
<p><%= Rails.configuration.terms %></p>
|
||||||
|
</div>
|
||||||
|
<div class="btn-list mt-4 text-right mt-8">
|
||||||
|
<%= button_to "I accept the terms and conditions.", terms_path, params: {accept: true}, class: "btn btn-primary btn-space" %>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -5,5 +5,4 @@ test:
|
||||||
adapter: test
|
adapter: test
|
||||||
|
|
||||||
production:
|
production:
|
||||||
adapter: redis
|
adapter: async
|
||||||
url: redis://localhost:6379/1
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Load terms and conditions.
|
||||||
|
|
||||||
|
terms = "#{Rails.root}/config/terms.txt"
|
||||||
|
|
||||||
|
Rails.configuration.terms = if File.exist?(terms)
|
||||||
|
File.read(terms)
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
|
@ -11,14 +11,16 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
# User resources.
|
# User resources.
|
||||||
scope '/u' do
|
scope '/u' do
|
||||||
get '/:user_uid/edit', to: 'users#edit', as: :edit_user
|
match '/terms', to: 'users#terms', via: [:get, :post]
|
||||||
patch '/:user_uid/edit', to: 'users#update', as: :update_user
|
|
||||||
|
|
||||||
# Handles login of greenlight provider accounts.
|
# Handles login of greenlight provider accounts.
|
||||||
post '/login', to: 'sessions#create', as: :create_session
|
post '/login', to: 'sessions#create', as: :create_session
|
||||||
|
|
||||||
# Log the user out of the session.
|
# Log the user out of the session.
|
||||||
get '/logout', to: 'sessions#destroy'
|
get '/logout', to: 'sessions#destroy'
|
||||||
|
|
||||||
|
get '/:user_uid/edit', to: 'users#edit', as: :edit_user
|
||||||
|
patch '/:user_uid/edit', to: 'users#update', as: :update_user
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handles launches from a trusted launcher.
|
# Handles launches from a trusted launcher.
|
||||||
|
|
|
@ -10,6 +10,7 @@ class CreateUsers < ActiveRecord::Migration[5.0]
|
||||||
t.string :social_uid
|
t.string :social_uid
|
||||||
t.string :image
|
t.string :image
|
||||||
t.string :password_digest, index: { unique: true }
|
t.string :password_digest, index: { unique: true }
|
||||||
|
t.boolean :accepted_terms, default: false
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,8 +39,9 @@ ActiveRecord::Schema.define(version: 20180504131705) do
|
||||||
t.string "social_uid"
|
t.string "social_uid"
|
||||||
t.string "image"
|
t.string "image"
|
||||||
t.string "password_digest"
|
t.string "password_digest"
|
||||||
t.datetime "created_at", null: false
|
t.boolean "accepted_terms", default: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
t.index ["password_digest"], name: "index_users_on_password_digest", unique: true
|
t.index ["password_digest"], name: "index_users_on_password_digest", unique: true
|
||||||
t.index ["room_id"], name: "index_users_on_room_id"
|
t.index ["room_id"], name: "index_users_on_room_id"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue