..." 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