forked from External/greenlight
Merge branch 'v2'
This commit is contained in:
commit
2775b18993
|
@ -36,9 +36,6 @@ class ApplicationController < ActionController::Base
|
||||||
# Manually handle BigBlueButton errors
|
# Manually handle BigBlueButton errors
|
||||||
rescue_from BigBlueButton::BigBlueButtonException, with: :handle_bigbluebutton_error
|
rescue_from BigBlueButton::BigBlueButtonException, with: :handle_bigbluebutton_error
|
||||||
|
|
||||||
# Manually Handle errors when application is in readonly mode
|
|
||||||
rescue_from ActiveRecord::ReadOnlyRecord, with: :handle_readonly_error
|
|
||||||
|
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
MEETING_NAME_LIMIT = 90
|
MEETING_NAME_LIMIT = 90
|
||||||
|
@ -56,7 +53,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def maintenance_mode?
|
def maintenance_mode?
|
||||||
if ENV["MAINTENANCE_MODE"] == "full"
|
if ENV["MAINTENANCE_MODE"] == "true"
|
||||||
render "errors/greenlight_error", status: 503, formats: :html,
|
render "errors/greenlight_error", status: 503, formats: :html,
|
||||||
locals: {
|
locals: {
|
||||||
status_code: 503,
|
status_code: 503,
|
||||||
|
@ -202,10 +199,4 @@ class ApplicationController < ActionController::Base
|
||||||
def handle_bigbluebutton_error
|
def handle_bigbluebutton_error
|
||||||
render "errors/bigbluebutton_error"
|
render "errors/bigbluebutton_error"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Manually Handle errors when application is in readonly mode
|
|
||||||
def handle_readonly_error
|
|
||||||
flash.clear
|
|
||||||
redirect_to request.referrer || root_path, flash: { alert: I18n.t("errors.maintenance.readonly") }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,8 +22,4 @@ class ApplicationRecord < ActiveRecord::Base
|
||||||
def to_param
|
def to_param
|
||||||
uid
|
uid
|
||||||
end
|
end
|
||||||
|
|
||||||
def readonly?
|
|
||||||
ENV["MAINTENANCE_MODE"] == "readonly"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Room < ApplicationRecord
|
||||||
# Update session info.
|
# Update session info.
|
||||||
unless meeting[:messageKey] == 'duplicateWarning'
|
unless meeting[:messageKey] == 'duplicateWarning'
|
||||||
update_attributes(sessions: sessions + 1,
|
update_attributes(sessions: sessions + 1,
|
||||||
last_session: DateTime.now) unless ENV["MAINTENANCE_MODE"] == "readonly"
|
last_session: DateTime.now)
|
||||||
end
|
end
|
||||||
rescue BigBlueButton::BigBlueButtonException => e
|
rescue BigBlueButton::BigBlueButtonException => e
|
||||||
puts "BigBlueButton failed on create: #{e.key}: #{e.message}"
|
puts "BigBlueButton failed on create: #{e.key}: #{e.message}"
|
||||||
|
|
|
@ -54,31 +54,14 @@ class User < ApplicationRecord
|
||||||
def from_omniauth(auth)
|
def from_omniauth(auth)
|
||||||
# Provider is the customer name if in loadbalanced config mode
|
# Provider is the customer name if in loadbalanced config mode
|
||||||
provider = auth['provider'] == "bn_launcher" ? auth['info']['customer'] : auth['provider']
|
provider = auth['provider'] == "bn_launcher" ? auth['info']['customer'] : auth['provider']
|
||||||
u = find_by(social_uid: auth['uid'], provider: provider)
|
find_or_initialize_by(social_uid: auth['uid'], provider: provider).tap do |u|
|
||||||
|
u.name = auth_name(auth) unless u.name
|
||||||
if ENV["MAINTENANCE_MODE"] == "readonly"
|
u.username = auth_username(auth) unless u.username
|
||||||
raise ActiveRecord::ReadOnlyRecord if u.nil?
|
u.email = auth_email(auth)
|
||||||
|
u.image = auth_image(auth)
|
||||||
return u
|
u.email_verified = true
|
||||||
|
u.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
return User.create(
|
|
||||||
name: auth_name(auth),
|
|
||||||
username: auth_username(auth),
|
|
||||||
email: auth_email(auth),
|
|
||||||
social_uid: auth['uid'],
|
|
||||||
provider: provider,
|
|
||||||
image: auth_image(auth),
|
|
||||||
email_verified: true
|
|
||||||
) if u.nil?
|
|
||||||
|
|
||||||
u.name = auth_name(auth) unless u.name
|
|
||||||
u.username = auth_username(auth) unless u.username
|
|
||||||
u.email = auth_email(auth)
|
|
||||||
u.image = auth_image(auth) unless u.image
|
|
||||||
u.email_verified = true
|
|
||||||
u.save!
|
|
||||||
u
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -10,10 +10,8 @@ fi
|
||||||
|
|
||||||
bundle exec rake db:create
|
bundle exec rake db:create
|
||||||
|
|
||||||
if [ "$MAINTENANCE_MODE" != "readonly" ] && [ "$MAINTENANCE_MODE" != "full" ]; then
|
if ! bundle exec rake db:migrate ; then
|
||||||
if ! bundle exec rake db:migrate ; then
|
export DB_MIGRATE_FAILED=1
|
||||||
export DB_MIGRATE_FAILED=1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bundle exec rake assets:precompile
|
bundle exec rake assets:precompile
|
||||||
|
|
|
@ -133,7 +133,6 @@ en:
|
||||||
maintenance:
|
maintenance:
|
||||||
message: Sorry, we're down for maintenance.
|
message: Sorry, we're down for maintenance.
|
||||||
help: We'll be back soon!
|
help: We'll be back soon!
|
||||||
readonly: This application is under maintenance. You will not be able to perform this action
|
|
||||||
migration_error:
|
migration_error:
|
||||||
contact_admin: If you are not an administrator, please contact one.
|
contact_admin: If you are not an administrator, please contact one.
|
||||||
continue: I'd like to stay using 1.0.
|
continue: I'd like to stay using 1.0.
|
||||||
|
|
|
@ -145,8 +145,7 @@ ENABLE_GOOGLE_CALENDAR_BUTTON=
|
||||||
# Set the application into Maintenance Mode
|
# Set the application into Maintenance Mode
|
||||||
#
|
#
|
||||||
# Current options supported:
|
# Current options supported:
|
||||||
# full: Renders an error page that does not allow users to access any of the features in the application
|
# true: Renders an error page that does not allow users to access any of the features in the application
|
||||||
# readonly: Sets the database to readonly mode, which allows users to use actions that dont write to the database
|
|
||||||
# false: Application runs normally
|
# false: Application runs normally
|
||||||
MAINTENANCE_MODE=false
|
MAINTENANCE_MODE=false
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue