GRN2-224: Added event logs and production caching (#739)

* Added event logs and production caching

* Added Support: before logs for easy identification

* Added more Support for log errors

* Reverted change to assets precompile check

* Added vendor assets to precompile list

* Travis fix
This commit is contained in:
farhatahmad 2019-08-14 14:25:52 -04:00 committed by Jesus Federico
parent f87c2bfd16
commit 89f36c1766
10 changed files with 41 additions and 12 deletions

View File

@ -44,8 +44,7 @@
@import "sessions";
@import "monolith.min.css";
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,500,500i,600,600i,700,700i&subset=latin-ext);
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500);
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500|Source+Sans+Pro:300,300i,400,400i,600,600i,700,700i&display=swap&subset=latin-ext);
* {
outline: none !important;

View File

@ -52,7 +52,7 @@ class AccountActivationsController < ApplicationController
begin
send_activation_email(@user)
rescue => e
logger.error "Error in email delivery: #{e}"
logger.error "Support: Error in email delivery: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
else
flash[:success] = I18n.t("email_sent", email_type: t("verify.verification"))

View File

@ -97,7 +97,7 @@ class AdminsController < ApplicationController
send_invitation_email(current_user.name, email, invitation.invite_token)
rescue => e
logger.error "Error in email delivery: #{e}"
logger.error "Support: Error in email delivery: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
else
flash[:success] = I18n.t("administrator.flash.invite", email: email)

View File

@ -39,7 +39,7 @@ class PasswordResetsController < ApplicationController
redirect_to new_password_reset_path
end
rescue => e
logger.error "Error in email delivery: #{e}"
logger.error "Support: Error in email delivery: #{e}"
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("delivery_error"))
end

View File

@ -42,6 +42,8 @@ class RoomsController < ApplicationController
room_params[:require_moderator_approval], room_params[:anyone_can_start], room_params[:all_join_moderator])
if @room.save
logger.info("Support: #{current_user.email} has created a new room #{@room.uid}.")
if room_params[:auto_join] == "1"
start
else
@ -138,6 +140,8 @@ class RoomsController < ApplicationController
.uniq[0..2]
end
logger.info("Support: #{current_user.present? ? current_user.email : @join_name} is joining room #{@room.uid}")
join_room(opts)
end
@ -166,6 +170,8 @@ class RoomsController < ApplicationController
# POST /:room_uid/start
def start
logger.info("Support: #{current_user.email} is starting room #{@room.uid}")
# Join the user in and start the meeting.
opts = default_meeting_options
opts[:user_is_moderator] = true
@ -178,6 +184,8 @@ class RoomsController < ApplicationController
begin
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
rescue BigBlueButton::BigBlueButtonException => e
logger.error("Support: #{@room.uid} start failed: #{e}")
redirect_to room_path, alert: I18n.t(e.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
end
@ -208,6 +216,8 @@ class RoomsController < ApplicationController
# GET /:room_uid/logout
def logout
logger.info("Support: #{current_user.present? ? current_user.email : 'Guest'} has left room #{@room.uid}")
# Redirect the correct page.
redirect_to @room
end

View File

@ -31,6 +31,8 @@ class SessionsController < ApplicationController
# POST /users/login
def create
logger.info("Support: #{session_params[:email]} is attempting to login.")
admin = User.find_by(email: session_params[:email])
if admin&.has_role? :super_admin
user = admin
@ -118,6 +120,8 @@ class SessionsController < ApplicationController
user = User.from_omniauth(@auth)
logger.info("Support: Auth user #{user.email} is attempting to login.")
# Add pending role if approval method and is a new user
if approval_registration && !@user_exists
user.add_role :pending
@ -143,7 +147,7 @@ class SessionsController < ApplicationController
end
end
rescue => e
logger.error "Error authenticating via omniauth: #{e}"
logger.error "Support: Error authenticating via omniauth: #{e}"
omniauth_fail
end
end

View File

@ -43,6 +43,8 @@ class UsersController < ApplicationController
# User has passed all validations required
@user.save
logger.info("Support: #{@user.email} user has been created.")
# Set user to pending and redirect if Approval Registration is set
if approval_registration
@user.add_role :pending
@ -161,6 +163,8 @@ class UsersController < ApplicationController
# DELETE /u/:user_uid
def destroy
logger.info("Support: #{current_user.email} is deleting #{@user.email}.")
if current_user && current_user == @user
@user.destroy
session.delete(:user_id)
@ -168,7 +172,7 @@ class UsersController < ApplicationController
begin
@user.destroy
rescue => e
logger.error "Error in user deletion: #{e}"
logger.error "Support: Error in user deletion: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("administrator.flash.delete_fail"))
else
flash[:success] = I18n.t("administrator.flash.delete")
@ -220,7 +224,7 @@ class UsersController < ApplicationController
begin
send_activation_email(@user)
rescue => e
logger.error "Error in email delivery: #{e}"
logger.error "Support: Error in email delivery: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
else
flash[:success] = I18n.t("email_sent", email_type: t("verify.verification"))
@ -235,7 +239,7 @@ class UsersController < ApplicationController
send_approval_user_signup_email(@user)
end
rescue => e
logger.error "Error in email delivery: #{e}"
logger.error "Support: Error in email delivery: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))
end
end
@ -245,6 +249,8 @@ class UsersController < ApplicationController
valid_user = @user.valid?
valid_captcha = Rails.configuration.recaptcha_enabled ? verify_recaptcha(model: @user) : true
logger.error("Support: #{@user.email} creation failed: User params are not valid.") unless valid_user
valid_user && valid_captcha
end

View File

@ -23,6 +23,8 @@ module SessionsHelper
session[:user_id] = user.id
logger.info("Support: #{user.email} has successfully logged in.")
# If there are not terms, or the user has accepted them, check for email verification
if !Rails.configuration.terms || user.accepted_terms
check_email_verified(user)

View File

@ -6,6 +6,14 @@ Rails.application.configure do
# Code is not reloaded between requests.
config.cache_classes = true
# Cache controller code
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.years.to_i}"
}
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
@ -29,7 +37,7 @@ Rails.application.configure do
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

View File

@ -8,9 +8,9 @@ Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w(pickr.min.js pickr.min.js.map monolith.min.css)