..." value="<%= @search %>">
<% unless @search.blank? %>
@@ -28,7 +36,7 @@
<% end %>
-
diff --git a/app/views/shared/modals/_invite_user_modal.html.erb b/app/views/shared/modals/_invite_user_modal.html.erb
new file mode 100644
index 00000000..b7680877
--- /dev/null
+++ b/app/views/shared/modals/_invite_user_modal.html.erb
@@ -0,0 +1,44 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+# Copyright (c) 2018 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 .
+%>
+
+
+
+
+
+
+
+
<%= t("modal.invite_user.title") %>
+
+
+ <%= form_for(:invite_user, url: invite_user_path) do |f| %>
+
diff --git a/app/views/user_mailer/approve_user.html.erb b/app/views/user_mailer/approve_user.html.erb
new file mode 100644
index 00000000..a66f918c
--- /dev/null
+++ b/app/views/user_mailer/approve_user.html.erb
@@ -0,0 +1,43 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+
diff --git a/app/views/user_mailer/approve_user.text.erb b/app/views/user_mailer/approve_user.text.erb
new file mode 100644
index 00000000..3d039952
--- /dev/null
+++ b/app/views/user_mailer/approve_user.text.erb
@@ -0,0 +1,27 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+<%= t('mailer.user.approve.subject') %>
+
+<%= t('mailer.user.approve.info') %>
+
+<%= t('mailer.user.approve.username', email: @user.email) %>
+
+<%= t('mailer.user.approve.signin') %>
+
+<%= @url %>
\ No newline at end of file
diff --git a/app/views/user_mailer/invite_email.html.erb b/app/views/user_mailer/invite_email.html.erb
new file mode 100644
index 00000000..d9921528
--- /dev/null
+++ b/app/views/user_mailer/invite_email.html.erb
@@ -0,0 +1,43 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+
diff --git a/app/views/user_mailer/invite_email.text.erb b/app/views/user_mailer/invite_email.text.erb
new file mode 100644
index 00000000..991ec71d
--- /dev/null
+++ b/app/views/user_mailer/invite_email.text.erb
@@ -0,0 +1,27 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+<%= t('mailer.user.invite.subject') %>
+
+<%= t('mailer.user.invite.info', name: @name) %>
+
+<%= t('mailer.user.invite.username', email: @email) %>
+
+<%= t('mailer.user.invite.signup') %>
+
+<%= @url %>
diff --git a/config/application.rb b/config/application.rb
index 2a5dc010..9cfdef7d 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -96,22 +96,30 @@ module Greenlight
# The maximum number of rooms included in one bbbapi call
config.pagination_number = ENV['PAGINATION_NUMBER'].to_i.zero? ? 25 : ENV['PAGINATION_NUMBER'].to_i
- # Default branding image if the user does not specify one
- config.branding_image_default = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png"
-
- # Default primary color if the user does not specify one
- config.primary_color_default = "#467fcf"
-
- # Default admin password
- config.admin_password_default = ENV['ADMIN_PASSWORD'] || 'administrator'
-
# Number of rows to display per page
- config.pagination_rows = ENV['NUMBER_OF_ROWS'].to_i.zero? ? 10 : ENV['NUMBER_OF_ROWS'].to_i
+ config.pagination_rows = ENV['NUMBER_OF_ROWS'].to_i.zero? ? 25 : ENV['NUMBER_OF_ROWS'].to_i
# Whether the user has defined the variables required for recaptcha
config.recaptcha_enabled = ENV['RECAPTCHA_SITE_KEY'].present? && ENV['RECAPTCHA_SECRET_KEY'].present?
# Show/hide "Add to Google Calendar" button in the room page
config.enable_google_calendar_button = (ENV['ENABLE_GOOGLE_CALENDAR_BUTTON'] == "true")
+
+ # Enum containing the different possible registration methods
+ config.registration_methods = { open: "0", invite: "1", approval: "2" }
+
+ # DEFAULTS
+
+ # Default branding image if the user does not specify one
+ config.branding_image_default = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png"
+
+ # Default primary color if the user does not specify one
+ config.primary_color_default = "#467fcf"
+
+ # Default registration method if the user does not specify one
+ config.registration_method_default = config.registration_methods[:open]
+
+ # Default admin password
+ config.admin_password_default = ENV['ADMIN_PASSWORD'] || 'administrator'
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 885afdc0..987f31e4 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -31,18 +31,30 @@ en:
color:
info: Change the primary color used across the website
title: Primary Color
+ registration:
+ info: Change the way that users register to the website
+ title: Registration Method
+ methods:
+ approval: Approve/Decline
+ invite: Join by Invitation
+ open: Open Registration
subtitle: Customize Greenlight
title: Site Settings
flash:
+ approved: User has been successfully approved.
banned: User has been successfully banned.
unbanned: User has been successfully unbanned.
delete: User deleted successfully
delete_fail: Failed to delete user
demoted: User has been successfully demoted
+ invite: Invite successfully sent to %{email}
+ invite_email_verification: ALLOW_MAIL_NOTIFICATIONS must be set to true in order to use this method
promoted: User has been successfully promoted
+ registration_method_updated: Registration method successfully updated
unauthorized: You are not authorized to perform actions on this user
title: Organization Settings
users:
+ invite: Invite User
edit:
title: Edit User Details
settings:
@@ -105,6 +117,7 @@ en:
unauthorized:
message: You do not have access to this application
help: If you believe this is a mistake, please contact your system administrator.
+
unprocessable:
message: Oops! Request is unprocessable.
help: Unfortunately this isn't a valid request.
@@ -157,6 +170,18 @@ en:
login_title: Sign in to your account
mailer:
user:
+ approve:
+ info: Your account has been approved.
+ signin: To access your personal rooms, click the button below and sign in.
+ signin_link: Sign In
+ subject: Account Approved
+ username: Your username is %{email}.
+ invite:
+ info: You have been invited to your own personal space by %{name}
+ signup: To signup using your email, click the button below and follow the steps.
+ signup_link: Sign Up
+ subject: Invitation to join BigBlueButton
+ username: Your username is %{email}.
password_reset:
title: 'Password reset'
welcome: It seems like you forgot your password for %{bigbluebutton}
@@ -191,6 +216,11 @@ en:
delete: I'm sure, delete this room.
keep: On second thought, I'll keep it.
warning: You will not be able to recover this room or any of its %{recordings_num} associated recordings.
+ invite_user:
+ email_placeholder: Enter the user's email
+ footer: The user will receive an email with instructions on how to sign up
+ send: Send Invite
+ title: Invite User
login:
or: or
with: Sign in with %{provider}
@@ -246,6 +276,15 @@ en:
unlisted: Unlisted
format:
presentation: Presentation
+ registration:
+ approval:
+ fail: Your account has not been approved yet. If multiples days have passed since you signed up, please contact your administrator.
+ signup: Your account was successfully created. It has been sent to an administrator for approval.
+ banned:
+ fail: You do not have access to this application. If you believe this is a mistake, please contact your administrator.
+ invite:
+ fail: Your token is either invalid or has expired. If you believe this is a mistake, please contact your administrator.
+ no_invite: You do not have an invitation to join. Please contact your administrator to receive one.
rename: Rename
reset_password:
subtitle: Reset Password
@@ -255,6 +294,7 @@ en:
roles:
administrator: Administrator
banned: Banned
+ pending: Pending
super_admin: Super Admin
user: User
room:
diff --git a/config/routes.rb b/config/routes.rb
index aecad233..e3ca5d3d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -45,6 +45,9 @@ Rails.application.routes.draw do
post '/demote/:user_uid', to: 'admins#demote', as: :admin_demote
post '/ban/:user_uid', to: 'admins#ban_user', as: :admin_ban
post '/unban/:user_uid', to: 'admins#unban_user', as: :admin_unban
+ post '/invite', to: 'admins#invite', as: :invite_user
+ post '/registration_method/:method', to: 'admins#registration_method', as: :admin_change_registration
+ post '/approve/:user_uid', to: 'admins#approve', as: :admin_approve
end
scope '/themes' do
diff --git a/db/migrate/20190507190710_create_invitations.rb b/db/migrate/20190507190710_create_invitations.rb
new file mode 100644
index 00000000..c4f62b02
--- /dev/null
+++ b/db/migrate/20190507190710_create_invitations.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateInvitations < ActiveRecord::Migration[5.0]
+ def change
+ create_table :invitations do |t|
+ t.string "email", null: false
+ t.string "provider", null: false
+ t.string "invite_token"
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 26db9b9b..7f282bd1 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20190326144939) do
+ActiveRecord::Schema.define(version: 20190507190710) do
create_table "features", force: :cascade do |t|
t.integer "setting_id"
@@ -22,6 +22,14 @@ ActiveRecord::Schema.define(version: 20190326144939) do
t.index ["setting_id"], name: "index_features_on_setting_id"
end
+ create_table "invitations", force: :cascade do |t|
+ t.string "email", null: false
+ t.string "provider", null: false
+ t.string "invite_token"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "roles", force: :cascade do |t|
t.string "name"
t.string "resource_type"
@@ -38,11 +46,11 @@ ActiveRecord::Schema.define(version: 20190326144939) do
t.string "name"
t.string "uid"
t.string "bbb_id"
- t.integer "sessions", default: 0
+ t.integer "sessions", default: 0
t.datetime "last_session"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "room_settings", default: "{ }"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "room_settings", default: "{ }"
t.string "moderator_pw"
t.string "attendee_pw"
t.index ["bbb_id"], name: "index_rooms_on_bbb_id"
@@ -70,8 +78,8 @@ ActiveRecord::Schema.define(version: 20190326144939) do
t.string "image"
t.string "password_digest"
t.boolean "accepted_terms", default: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "email_verified", default: false
t.string "language", default: "default"
t.string "reset_digest"
diff --git a/sample.env b/sample.env
index b26beea9..037c36fa 100644
--- a/sample.env
+++ b/sample.env
@@ -136,8 +136,8 @@ ROOM_FEATURES=default-client,mute-on-join
PAGINATION_NUMBER=25
# Specify the maximum number of rows that should be displayed per page for a paginated table
-# Default is set to 10 rows
-NUMBER_OF_ROWS=10
+# Default is set to 25 rows
+NUMBER_OF_ROWS=25
# Specify if you want to display the Google Calendar button
# ENABLE_GOOGLE_CALENDAR_BUTTON=true|false
diff --git a/spec/controllers/account_activations_controller_spec.rb b/spec/controllers/account_activations_controller_spec.rb
index 721d00d6..9c5c5632 100644
--- a/spec/controllers/account_activations_controller_spec.rb
+++ b/spec/controllers/account_activations_controller_spec.rb
@@ -72,6 +72,17 @@ describe AccountActivationsController, type: :controller do
expect(flash[:alert]).to be_present
expect(response).to redirect_to(root_path)
end
+
+ it "redirects a pending user to root with a flash" do
+ @user = create(:user, email_verified: false, provider: "greenlight")
+
+ @user.add_role :pending
+
+ get :edit, params: { email: @user.email, token: @user.activation_token }
+
+ expect(flash[:success]).to be_present
+ expect(response).to redirect_to(root_path)
+ end
end
describe "GET #resend" do
diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb
index 1024a6a4..c476821b 100644
--- a/spec/controllers/admins_controller_spec.rb
+++ b/spec/controllers/admins_controller_spec.rb
@@ -109,6 +109,56 @@ describe AdminsController, type: :controller do
expect(response).to redirect_to(admins_path)
end
end
+
+ context "POST #invite" do
+ before do
+ allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
+ allow_any_instance_of(ApplicationController).to receive(:allow_greenlight_users?).and_return(true)
+ allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
+ end
+
+ it "invites a user" do
+ @request.session[:user_id] = @admin.id
+ email = Faker::Internet.email
+ post :invite, params: { invite_user: { email: email } }
+
+ invite = Invitation.find_by(email: email, provider: "greenlight")
+
+ expect(invite.present?).to eq(true)
+ expect(flash[:success]).to be_present
+ expect(response).to redirect_to(admins_path)
+ end
+
+ it "sends an invitation email" do
+ @request.session[:user_id] = @admin.id
+ email = Faker::Internet.email
+
+ params = { invite_user: { email: email } }
+ expect { post :invite, params: params }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+ end
+
+ context "POST #approve" do
+ it "approves a pending user" do
+ @request.session[:user_id] = @admin.id
+
+ @user.add_role :pending
+
+ post :approve, params: { user_uid: @user.uid }
+
+ expect(@user.has_role?(:pending)).to eq(false)
+ expect(flash[:success]).to be_present
+ expect(response).to redirect_to(admins_path)
+ end
+
+ it "sends the user an email telling them theyre approved" do
+ @request.session[:user_id] = @admin.id
+
+ @user.add_role :pending
+ params = { user_uid: @user.uid }
+ expect { post :approve, params: params }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+ end
end
describe "User Design" do
@@ -142,7 +192,38 @@ describe AdminsController, type: :controller do
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Primary Color")
expect(feature[:value]).to eq(primary_color)
- expect(response).to redirect_to(admins_path(setting: "site_settings"))
+ expect(response).to redirect_to(admins_path)
+ end
+ end
+
+ context "POST #registration_method" do
+ it "changes the registration method for the given context" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
+ allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
+ allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
+
+ @request.session[:user_id] = @admin.id
+
+ post :registration_method, params: { method: "invite" }
+
+ feature = Setting.find_by(provider: "provider1").features.find_by(name: "Registration Method")
+
+ expect(feature[:value]).to eq(Rails.configuration.registration_methods[:invite])
+ expect(flash[:success]).to be_present
+ expect(response).to redirect_to(admins_path)
+ end
+
+ it "does not allow the user to change to invite if emails are off" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(false)
+ allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
+ allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
+
+ @request.session[:user_id] = @admin.id
+
+ post :registration_method, params: { method: "invite" }
+
+ expect(flash[:alert]).to be_present
+ expect(response).to redirect_to(admins_path)
end
end
end
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index e1a47f61..2c2ce500 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -32,14 +32,28 @@ describe ApplicationController do
end
context "roles" do
- it "redirects a banned user to a 401 and logs them out" do
+ before do
@user = create(:user)
+ end
+
+ it "redirects a banned user to a 401 and logs them out" do
@user.add_role :denied
@request.session[:user_id] = @user.id
get :index
expect(@request.session[:user_id]).to be_nil
- expect(response).to redirect_to(unauthorized_path)
+ expect(flash[:alert]).to be_present
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "redirects a pending user to a 401 and logs them out" do
+ @user.add_role :pending
+ @request.session[:user_id] = @user.id
+
+ get :index
+ expect(@request.session[:user_id]).to be_nil
+ expect(flash[:alert]).to be_present
+ expect(response).to redirect_to(root_path)
end
end
end
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index cdcc1e6e..5207cfc7 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -169,7 +169,9 @@ describe UsersController, type: :controller do
end
context "allow email verification" do
- before { allow(Rails.configuration).to receive(:enable_email_verification).and_return(true) }
+ before do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
+ end
it "should raise if there there is a delivery failure" do
params = random_valid_user_params
@@ -179,6 +181,91 @@ describe UsersController, type: :controller do
raise :anyerror
end.to raise_error { :anyerror }
end
+
+ context "enable invite registration" do
+ before do
+ allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
+ allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
+ end
+
+ it "rejects the user if they are not invited" do
+ get :new
+
+ expect(flash[:alert]).to be_present
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "allows the user to signup if they are invited" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(false)
+
+ params = random_valid_user_params
+ invite = Invitation.create(email: params[:user][:name], provider: "greenlight")
+ @request.session[:invite_token] = invite.invite_token
+
+ post :create, params: params
+
+ u = User.find_by(name: params[:user][:name], email: params[:user][:email])
+ expect(response).to redirect_to(u.main_room)
+ end
+
+ it "verifies the user if they sign up with the email they receieved the invite with" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
+
+ params = random_valid_user_params
+ invite = Invitation.create(email: params[:user][:email], provider: "greenlight")
+ @request.session[:invite_token] = invite.invite_token
+
+ post :create, params: params
+
+ u = User.find_by(name: params[:user][:name], email: params[:user][:email])
+ expect(response).to redirect_to(u.main_room)
+ end
+
+ it "asks the user to verify if they signup with a different email" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
+
+ params = random_valid_user_params
+ invite = Invitation.create(email: Faker::Internet.email, provider: "greenlight")
+ @request.session[:invite_token] = invite.invite_token
+
+ post :create, params: params
+
+ expect(User.exists?(name: params[:user][:name], email: params[:user][:email])).to eq(true)
+ expect(flash[:success]).to be_present
+ expect(response).to redirect_to(root_path)
+ end
+ end
+
+ context "enable approval registration" do
+ before do
+ allow_any_instance_of(Registrar).to receive(:approval_registration).and_return(true)
+ allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
+ end
+
+ it "allows any user to sign up" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(false)
+
+ params = random_valid_user_params
+
+ post :create, params: params
+
+ expect(User.exists?(name: params[:user][:name], email: params[:user][:email])).to eq(true)
+ expect(flash[:success]).to be_present
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "sets the user to pending on sign up" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(false)
+
+ params = random_valid_user_params
+
+ post :create, params: params
+
+ u = User.find_by(name: params[:user][:name], email: params[:user][:email])
+
+ expect(u.has_role?(:pending)).to eq(true)
+ end
+ end
end
it "redirects to main room if already authenticated" do
diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb
index 00554969..263eae53 100644
--- a/test/mailers/previews/user_mailer_preview.rb
+++ b/test/mailers/previews/user_mailer_preview.rb
@@ -1,13 +1,18 @@
# frozen_string_literal: true
class UserMailerPreview < ActionMailer::Preview
+ def initialize
+ @logo = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png"
+ @color = "#467fcf"
+ end
+
# Preview this email at
# http://localhost:3000/rails/mailers/user_mailer/password_reset
def password_reset
user = User.first
user.reset_token = User.new_token
url = "http://example.com" + "/password_resets/" + user.reset_token + "/edit?email=" + user.email
- UserMailer.password_reset(user, url)
+ UserMailer.password_reset(user, url, @logo, @color)
end
# Preview this email at
@@ -15,6 +20,19 @@ class UserMailerPreview < ActionMailer::Preview
def verify_email
user = User.first
url = "http://example.com" + "/u/verify/confirm/" + user.uid
- UserMailer.verify_email(user, url)
+ UserMailer.verify_email(user, url, @logo, @color)
+ end
+
+ # Preview this email at
+ # http://localhost:3000/rails/mailers/user_mailer/invite_email
+ def invite_email
+ UserMailer.invite_email("Example User", "from@example.com", "http://example.com/signup", @logo, @color)
+ end
+
+ # Preview this email at
+ # http://localhost:3000/rails/mailers/user_mailer/approve_user
+ def approve_user
+ user = User.first
+ UserMailer.approve_user(user, "http://example.com/", @logo, @color)
end
end
From 251d85d88ae97064f8dfd80c5f23115bf0f775ea Mon Sep 17 00:00:00 2001
From: shawn-higgins1
Date: Tue, 21 May 2019 14:25:28 -0400
Subject: [PATCH 2/3] Notify admins when a approval/invite user signs up
---
app/controllers/concerns/emailer.rb | 19 ++++++++
app/controllers/sessions_controller.rb | 11 ++++-
app/controllers/users_controller.rb | 15 +++++++
app/mailers/user_mailer.rb | 18 ++++++++
.../user_mailer/approval_user_signup.html.erb | 43 +++++++++++++++++++
.../user_mailer/approval_user_signup.text.erb | 27 ++++++++++++
.../user_mailer/invite_user_signup.html.erb | 39 +++++++++++++++++
.../user_mailer/invite_user_signup.text.erb | 25 +++++++++++
config/locales/en.yml | 11 +++++
spec/controllers/sessions_controller_spec.rb | 28 ++++++++++++
spec/controllers/users_controller_spec.rb | 22 ++++++++++
test/mailers/previews/user_mailer_preview.rb | 14 ++++++
12 files changed, 270 insertions(+), 2 deletions(-)
create mode 100644 app/views/user_mailer/approval_user_signup.html.erb
create mode 100644 app/views/user_mailer/approval_user_signup.text.erb
create mode 100644 app/views/user_mailer/invite_user_signup.html.erb
create mode 100644 app/views/user_mailer/invite_user_signup.text.erb
diff --git a/app/controllers/concerns/emailer.rb b/app/controllers/concerns/emailer.rb
index c4a22e83..cc094bfd 100644
--- a/app/controllers/concerns/emailer.rb
+++ b/app/controllers/concerns/emailer.rb
@@ -41,6 +41,14 @@ module Emailer
UserMailer.approve_user(user, root_url, logo_image, user_color).deliver_now
end
+ def send_approval_user_signup_email(user)
+ UserMailer.approval_user_signup(user, root_url, logo_image, user_color, admin_emails).deliver_now
+ end
+
+ def send_invite_user_signup_email(user)
+ UserMailer.invite_user_signup(user, root_url, logo_image, user_color, admin_emails).deliver_now
+ end
+
private
# Returns the link the user needs to click to verify their account
@@ -48,6 +56,17 @@ module Emailer
edit_account_activation_url(token: @user.activation_token, email: @user.email)
end
+ def admin_emails
+ admins = User.with_role(:admin)
+
+ if Rails.configuration.loadbalanced_configuration
+ admins = admins.without_role(:super_admin)
+ .where(provider: user_settings_provider)
+ end
+
+ admins.collect(&:email).join(",")
+ end
+
def reset_link
edit_password_reset_url(@user.reset_token, email: @user.email)
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index e08bb005..7e1fff5c 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -18,6 +18,7 @@
class SessionsController < ApplicationController
include Registrar
+ include Emailer
skip_before_action :verify_authenticity_token, only: [:omniauth, :fail]
@@ -49,18 +50,24 @@ class SessionsController < ApplicationController
begin
@auth = request.env['omniauth.auth']
@user_exists = check_user_exists
-
+
# If using invitation registration method, make sure user is invited
return redirect_to root_path, flash: { alert: I18n.t("registration.invite.no_invite") } unless passes_invite_reqs
-
+
user = User.from_omniauth(@auth)
# Add pending role if approval method and is a new user
if approval_registration && !@user_exists
user.add_role :pending
+
+ # Inform admins that a user signed up if emails are turned on
+ send_approval_user_signup_email(user) if Rails.configuration.enable_email_verification
+
return redirect_to root_path, flash: { success: I18n.t("registration.approval.signup") }
end
+ send_invite_user_signup_email(user) if Rails.configuration.enable_email_verification && invite_registration && !@user_exists
+
login(user)
rescue => e
logger.error "Error authenticating via omniauth: #{e}"
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index cdf60820..4b2ba771 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -50,6 +50,8 @@ class UsersController < ApplicationController
flash: { success: I18n.t("registration.approval.signup") } unless Rails.configuration.enable_email_verification
end
+ send_registration_email if Rails.configuration.enable_email_verification
+
# Sign in automatically if email verification is disabled or if user is already verified.
login(@user) && return if !Rails.configuration.enable_email_verification || @user.email_verified
@@ -193,6 +195,19 @@ class UsersController < ApplicationController
end
end
+ def send_registration_email
+ begin
+ if invite_registration
+ send_invite_user_signup_email(@user)
+ elsif approval_registration
+ send_approval_user_signup_email(@user)
+ end
+ rescue => e
+ logger.error "Error in email delivery: #{e}"
+ flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
+ end
+ end
+
# Add validation errors to model if they exist
def valid_user_or_captcha
valid_user = @user.valid?
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index 7f911b6b..6332558c 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -51,4 +51,22 @@ class UserMailer < ApplicationMailer
@color = color
mail to: user.email, subject: t('mailer.user.approve.subject')
end
+
+ def approval_user_signup(user, url, image, color, admin_emails)
+ @user = user
+ @url = url + "admins"
+ @image = image
+ @color = color
+
+ mail to: admin_emails, subject: t('mailer.user.approve.signup.subject')
+ end
+
+ def invite_user_signup(user, url, image, color, admin_emails)
+ @user = user
+ @url = url + "admins"
+ @image = image
+ @color = color
+
+ mail to: admin_emails, subject: t('mailer.user.invite.signup.subject')
+ end
end
diff --git a/app/views/user_mailer/approval_user_signup.html.erb b/app/views/user_mailer/approval_user_signup.html.erb
new file mode 100644
index 00000000..fafae3b3
--- /dev/null
+++ b/app/views/user_mailer/approval_user_signup.html.erb
@@ -0,0 +1,43 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+
diff --git a/app/views/user_mailer/approval_user_signup.text.erb b/app/views/user_mailer/approval_user_signup.text.erb
new file mode 100644
index 00000000..418f08d6
--- /dev/null
+++ b/app/views/user_mailer/approval_user_signup.text.erb
@@ -0,0 +1,27 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+<%= t('mailer.user.approve.signup.subject') %>
+
+<%= t('mailer.user.approve.signup.info') %>
+
+<%= t('mailer.user.approve.signup.username', name: @user.name, email: @user.email) %>
+
+<%= t('mailer.user.approve.signup.more-info') %>
+
+<%= @url %>
\ No newline at end of file
diff --git a/app/views/user_mailer/invite_user_signup.html.erb b/app/views/user_mailer/invite_user_signup.html.erb
new file mode 100644
index 00000000..2a950e78
--- /dev/null
+++ b/app/views/user_mailer/invite_user_signup.html.erb
@@ -0,0 +1,39 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+
diff --git a/app/views/user_mailer/invite_user_signup.text.erb b/app/views/user_mailer/invite_user_signup.text.erb
new file mode 100644
index 00000000..2f61d9af
--- /dev/null
+++ b/app/views/user_mailer/invite_user_signup.text.erb
@@ -0,0 +1,25 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+#
+# Copyright (c) 2018 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 .
+%>
+
+<%= t('mailer.user.invite.signup.subject') %>
+
+<%= t('mailer.user.invite.signup.info') %>
+
+<%= t('mailer.user.invite.signup.username', name: @user.name, email: @user.email) %>
+
+<%= @url %>
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 987f31e4..251d4343 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -174,12 +174,23 @@ en:
info: Your account has been approved.
signin: To access your personal rooms, click the button below and sign in.
signin_link: Sign In
+ signup:
+ info: A new user has signed up to use Greenlight.
+ more-info: To allow this user to access Greenlight you must approve their account in organization settings.
+ admins_link: Visit the Organization Page
+ subject: New Greenlight User Sign Up
+ username: The user signed up with the name %{name} and the email %{email}.
subject: Account Approved
username: Your username is %{email}.
invite:
info: You have been invited to your own personal space by %{name}
signup: To signup using your email, click the button below and follow the steps.
signup_link: Sign Up
+ signup:
+ info: A user that was invited has signed up to use Greenlight.
+ admins_link: Visit the Organization Page
+ subject: New Greenlight User Sign Up
+ username: The user signed up with the name %{name} and the email %{email}.
subject: Invitation to join BigBlueButton
username: Your username is %{email}.
password_reset:
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index 9720194a..ddd25ddf 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -223,6 +223,34 @@ describe SessionsController, type: :controller do
expect(response).to redirect_to(root_path)
end
+
+ context 'registration notification emails' do
+ before do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
+ @user = create(:user, provider: "greenlight")
+ @admin = create(:user, provider: "greenlight", email: "test@example.com")
+ @admin.add_role :admin
+ end
+
+ it "should notify admin on new user signup with approve/reject registration" do
+ allow_any_instance_of(Registrar).to receive(:approval_registration).and_return(true)
+
+ request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher]
+
+ expect { get :omniauth, params: { provider: 'bn_launcher' } }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+
+ it "should notify admin on new user signup with invite registration" do
+ allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
+
+ invite = Invitation.create(email: "user@google.com", provider: "greenlight")
+ @request.session[:invite_token] = invite.invite_token
+
+ request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher]
+
+ expect { get :omniauth, params: { provider: 'bn_launcher' } }.to change { ActionMailer::Base.deliveries.count }.by(1)
+ end
+ end
end
it "should not create session without omniauth env set for bn_launcher" do
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 5207cfc7..7405d23d 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -186,6 +186,17 @@ describe UsersController, type: :controller do
before do
allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
+ @user = create(:user, provider: "greenlight")
+ @admin = create(:user, provider: "greenlight", email: "test@example.com")
+ @admin.add_role :admin
+ end
+
+ it "should notify admins that user signed up" do
+ params = random_valid_user_params
+ invite = Invitation.create(email: params[:user][:email], provider: "greenlight")
+ @request.session[:invite_token] = invite.invite_token
+
+ expect { post :create, params: params }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
it "rejects the user if they are not invited" do
@@ -240,6 +251,9 @@ describe UsersController, type: :controller do
before do
allow_any_instance_of(Registrar).to receive(:approval_registration).and_return(true)
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
+ @user = create(:user, provider: "greenlight")
+ @admin = create(:user, provider: "greenlight", email: "test@example.com")
+ @admin.add_role :admin
end
it "allows any user to sign up" do
@@ -265,6 +279,14 @@ describe UsersController, type: :controller do
expect(u.has_role?(:pending)).to eq(true)
end
+
+ it "notifies admins that a user signed up" do
+ allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
+
+ params = random_valid_user_params
+
+ expect { post :create, params: params }.to change { ActionMailer::Base.deliveries.count }.by(2)
+ end
end
end
diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb
index 263eae53..97498ec4 100644
--- a/test/mailers/previews/user_mailer_preview.rb
+++ b/test/mailers/previews/user_mailer_preview.rb
@@ -35,4 +35,18 @@ class UserMailerPreview < ActionMailer::Preview
user = User.first
UserMailer.approve_user(user, "http://example.com/", @logo, @color)
end
+
+ # Preview this email at
+ # http://localhost:3000/rails/mailers/user_mailer/approval_user_signup
+ def approval_user_signup
+ user = User.first
+ UserMailer.approval_user_signup(user, "http://example.com/", @logo, @color, "test@example.com")
+ end
+
+ # Preview this email at
+ # http://localhost:3000/rails/mailers/user_mailer/invite_user_signup
+ def invite_user_signup
+ user = User.first
+ UserMailer.invite_user_signup(user, "http://example.com/", @logo, @color, "test@example.com")
+ end
end
From 0360c78219209351395c630eddea1ae7a9602cef Mon Sep 17 00:00:00 2001
From: shawn-higgins1
Date: Tue, 21 May 2019 14:37:27 -0400
Subject: [PATCH 3/3] Revert "Notify admins when a approval/invite user signs
up"
This reverts commit 251d85d88ae97064f8dfd80c5f23115bf0f775ea.
---
app/controllers/concerns/emailer.rb | 19 --------
app/controllers/sessions_controller.rb | 11 +----
app/controllers/users_controller.rb | 15 -------
app/mailers/user_mailer.rb | 18 --------
.../user_mailer/approval_user_signup.html.erb | 43 -------------------
.../user_mailer/approval_user_signup.text.erb | 27 ------------
.../user_mailer/invite_user_signup.html.erb | 39 -----------------
.../user_mailer/invite_user_signup.text.erb | 25 -----------
config/locales/en.yml | 11 -----
spec/controllers/sessions_controller_spec.rb | 28 ------------
spec/controllers/users_controller_spec.rb | 22 ----------
test/mailers/previews/user_mailer_preview.rb | 14 ------
12 files changed, 2 insertions(+), 270 deletions(-)
delete mode 100644 app/views/user_mailer/approval_user_signup.html.erb
delete mode 100644 app/views/user_mailer/approval_user_signup.text.erb
delete mode 100644 app/views/user_mailer/invite_user_signup.html.erb
delete mode 100644 app/views/user_mailer/invite_user_signup.text.erb
diff --git a/app/controllers/concerns/emailer.rb b/app/controllers/concerns/emailer.rb
index cc094bfd..c4a22e83 100644
--- a/app/controllers/concerns/emailer.rb
+++ b/app/controllers/concerns/emailer.rb
@@ -41,14 +41,6 @@ module Emailer
UserMailer.approve_user(user, root_url, logo_image, user_color).deliver_now
end
- def send_approval_user_signup_email(user)
- UserMailer.approval_user_signup(user, root_url, logo_image, user_color, admin_emails).deliver_now
- end
-
- def send_invite_user_signup_email(user)
- UserMailer.invite_user_signup(user, root_url, logo_image, user_color, admin_emails).deliver_now
- end
-
private
# Returns the link the user needs to click to verify their account
@@ -56,17 +48,6 @@ module Emailer
edit_account_activation_url(token: @user.activation_token, email: @user.email)
end
- def admin_emails
- admins = User.with_role(:admin)
-
- if Rails.configuration.loadbalanced_configuration
- admins = admins.without_role(:super_admin)
- .where(provider: user_settings_provider)
- end
-
- admins.collect(&:email).join(",")
- end
-
def reset_link
edit_password_reset_url(@user.reset_token, email: @user.email)
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 7e1fff5c..e08bb005 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -18,7 +18,6 @@
class SessionsController < ApplicationController
include Registrar
- include Emailer
skip_before_action :verify_authenticity_token, only: [:omniauth, :fail]
@@ -50,24 +49,18 @@ class SessionsController < ApplicationController
begin
@auth = request.env['omniauth.auth']
@user_exists = check_user_exists
-
+
# If using invitation registration method, make sure user is invited
return redirect_to root_path, flash: { alert: I18n.t("registration.invite.no_invite") } unless passes_invite_reqs
-
+
user = User.from_omniauth(@auth)
# Add pending role if approval method and is a new user
if approval_registration && !@user_exists
user.add_role :pending
-
- # Inform admins that a user signed up if emails are turned on
- send_approval_user_signup_email(user) if Rails.configuration.enable_email_verification
-
return redirect_to root_path, flash: { success: I18n.t("registration.approval.signup") }
end
- send_invite_user_signup_email(user) if Rails.configuration.enable_email_verification && invite_registration && !@user_exists
-
login(user)
rescue => e
logger.error "Error authenticating via omniauth: #{e}"
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 4b2ba771..cdf60820 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -50,8 +50,6 @@ class UsersController < ApplicationController
flash: { success: I18n.t("registration.approval.signup") } unless Rails.configuration.enable_email_verification
end
- send_registration_email if Rails.configuration.enable_email_verification
-
# Sign in automatically if email verification is disabled or if user is already verified.
login(@user) && return if !Rails.configuration.enable_email_verification || @user.email_verified
@@ -195,19 +193,6 @@ class UsersController < ApplicationController
end
end
- def send_registration_email
- begin
- if invite_registration
- send_invite_user_signup_email(@user)
- elsif approval_registration
- send_approval_user_signup_email(@user)
- end
- rescue => e
- logger.error "Error in email delivery: #{e}"
- flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
- end
- end
-
# Add validation errors to model if they exist
def valid_user_or_captcha
valid_user = @user.valid?
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index 6332558c..7f911b6b 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -51,22 +51,4 @@ class UserMailer < ApplicationMailer
@color = color
mail to: user.email, subject: t('mailer.user.approve.subject')
end
-
- def approval_user_signup(user, url, image, color, admin_emails)
- @user = user
- @url = url + "admins"
- @image = image
- @color = color
-
- mail to: admin_emails, subject: t('mailer.user.approve.signup.subject')
- end
-
- def invite_user_signup(user, url, image, color, admin_emails)
- @user = user
- @url = url + "admins"
- @image = image
- @color = color
-
- mail to: admin_emails, subject: t('mailer.user.invite.signup.subject')
- end
end
diff --git a/app/views/user_mailer/approval_user_signup.html.erb b/app/views/user_mailer/approval_user_signup.html.erb
deleted file mode 100644
index fafae3b3..00000000
--- a/app/views/user_mailer/approval_user_signup.html.erb
+++ /dev/null
@@ -1,43 +0,0 @@
-<%
-# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
-#
-# Copyright (c) 2018 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 .
-%>
-
-
diff --git a/app/views/user_mailer/approval_user_signup.text.erb b/app/views/user_mailer/approval_user_signup.text.erb
deleted file mode 100644
index 418f08d6..00000000
--- a/app/views/user_mailer/approval_user_signup.text.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-<%
-# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
-#
-# Copyright (c) 2018 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 .
-%>
-
-<%= t('mailer.user.approve.signup.subject') %>
-
-<%= t('mailer.user.approve.signup.info') %>
-
-<%= t('mailer.user.approve.signup.username', name: @user.name, email: @user.email) %>
-
-<%= t('mailer.user.approve.signup.more-info') %>
-
-<%= @url %>
\ No newline at end of file
diff --git a/app/views/user_mailer/invite_user_signup.html.erb b/app/views/user_mailer/invite_user_signup.html.erb
deleted file mode 100644
index 2a950e78..00000000
--- a/app/views/user_mailer/invite_user_signup.html.erb
+++ /dev/null
@@ -1,39 +0,0 @@
-<%
-# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
-#
-# Copyright (c) 2018 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 .
-%>
-
-
diff --git a/app/views/user_mailer/invite_user_signup.text.erb b/app/views/user_mailer/invite_user_signup.text.erb
deleted file mode 100644
index 2f61d9af..00000000
--- a/app/views/user_mailer/invite_user_signup.text.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<%
-# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
-#
-# Copyright (c) 2018 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 .
-%>
-
-<%= t('mailer.user.invite.signup.subject') %>
-
-<%= t('mailer.user.invite.signup.info') %>
-
-<%= t('mailer.user.invite.signup.username', name: @user.name, email: @user.email) %>
-
-<%= @url %>
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 251d4343..987f31e4 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -174,23 +174,12 @@ en:
info: Your account has been approved.
signin: To access your personal rooms, click the button below and sign in.
signin_link: Sign In
- signup:
- info: A new user has signed up to use Greenlight.
- more-info: To allow this user to access Greenlight you must approve their account in organization settings.
- admins_link: Visit the Organization Page
- subject: New Greenlight User Sign Up
- username: The user signed up with the name %{name} and the email %{email}.
subject: Account Approved
username: Your username is %{email}.
invite:
info: You have been invited to your own personal space by %{name}
signup: To signup using your email, click the button below and follow the steps.
signup_link: Sign Up
- signup:
- info: A user that was invited has signed up to use Greenlight.
- admins_link: Visit the Organization Page
- subject: New Greenlight User Sign Up
- username: The user signed up with the name %{name} and the email %{email}.
subject: Invitation to join BigBlueButton
username: Your username is %{email}.
password_reset:
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index ddd25ddf..9720194a 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -223,34 +223,6 @@ describe SessionsController, type: :controller do
expect(response).to redirect_to(root_path)
end
-
- context 'registration notification emails' do
- before do
- allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
- @user = create(:user, provider: "greenlight")
- @admin = create(:user, provider: "greenlight", email: "test@example.com")
- @admin.add_role :admin
- end
-
- it "should notify admin on new user signup with approve/reject registration" do
- allow_any_instance_of(Registrar).to receive(:approval_registration).and_return(true)
-
- request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher]
-
- expect { get :omniauth, params: { provider: 'bn_launcher' } }.to change { ActionMailer::Base.deliveries.count }.by(1)
- end
-
- it "should notify admin on new user signup with invite registration" do
- allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
-
- invite = Invitation.create(email: "user@google.com", provider: "greenlight")
- @request.session[:invite_token] = invite.invite_token
-
- request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:bn_launcher]
-
- expect { get :omniauth, params: { provider: 'bn_launcher' } }.to change { ActionMailer::Base.deliveries.count }.by(1)
- end
- end
end
it "should not create session without omniauth env set for bn_launcher" do
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 7405d23d..5207cfc7 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -186,17 +186,6 @@ describe UsersController, type: :controller do
before do
allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
- @user = create(:user, provider: "greenlight")
- @admin = create(:user, provider: "greenlight", email: "test@example.com")
- @admin.add_role :admin
- end
-
- it "should notify admins that user signed up" do
- params = random_valid_user_params
- invite = Invitation.create(email: params[:user][:email], provider: "greenlight")
- @request.session[:invite_token] = invite.invite_token
-
- expect { post :create, params: params }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
it "rejects the user if they are not invited" do
@@ -251,9 +240,6 @@ describe UsersController, type: :controller do
before do
allow_any_instance_of(Registrar).to receive(:approval_registration).and_return(true)
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
- @user = create(:user, provider: "greenlight")
- @admin = create(:user, provider: "greenlight", email: "test@example.com")
- @admin.add_role :admin
end
it "allows any user to sign up" do
@@ -279,14 +265,6 @@ describe UsersController, type: :controller do
expect(u.has_role?(:pending)).to eq(true)
end
-
- it "notifies admins that a user signed up" do
- allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
-
- params = random_valid_user_params
-
- expect { post :create, params: params }.to change { ActionMailer::Base.deliveries.count }.by(2)
- end
end
end
diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb
index 97498ec4..263eae53 100644
--- a/test/mailers/previews/user_mailer_preview.rb
+++ b/test/mailers/previews/user_mailer_preview.rb
@@ -35,18 +35,4 @@ class UserMailerPreview < ActionMailer::Preview
user = User.first
UserMailer.approve_user(user, "http://example.com/", @logo, @color)
end
-
- # Preview this email at
- # http://localhost:3000/rails/mailers/user_mailer/approval_user_signup
- def approval_user_signup
- user = User.first
- UserMailer.approval_user_signup(user, "http://example.com/", @logo, @color, "test@example.com")
- end
-
- # Preview this email at
- # http://localhost:3000/rails/mailers/user_mailer/invite_user_signup
- def invite_user_signup
- user = User.first
- UserMailer.invite_user_signup(user, "http://example.com/", @logo, @color, "test@example.com")
- end
end