diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d81ff084..839ba691 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,9 +36,6 @@ class ApplicationController < ActionController::Base # Manually handle BigBlueButton errors 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 MEETING_NAME_LIMIT = 90 @@ -50,7 +47,7 @@ class ApplicationController < ActionController::Base end def maintenance_mode? - if ENV["MAINTENANCE_MODE"] == "full" + if ENV["MAINTENANCE_MODE"] == "true" render "errors/greenlight_error", status: 503, formats: :html, locals: { status_code: 503, @@ -193,10 +190,4 @@ class ApplicationController < ActionController::Base def handle_bigbluebutton_error render "errors/bigbluebutton_error" 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 diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 58709624..f315237b 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -22,8 +22,4 @@ class ApplicationRecord < ActiveRecord::Base def to_param uid end - - def readonly? - ENV["MAINTENANCE_MODE"] == "readonly" - end end diff --git a/app/models/room.rb b/app/models/room.rb index b6862591..3e5a636a 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -66,7 +66,7 @@ class Room < ApplicationRecord # Update session info. unless meeting[:messageKey] == 'duplicateWarning' update_attributes(sessions: sessions + 1, - last_session: DateTime.now) unless ENV["MAINTENANCE_MODE"] == "readonly" + last_session: DateTime.now) end rescue BigBlueButton::BigBlueButtonException => e puts "BigBlueButton failed on create: #{e.key}: #{e.message}" diff --git a/app/models/user.rb b/app/models/user.rb index a3428a7c..f7af9a35 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -55,31 +55,14 @@ class User < ApplicationRecord def from_omniauth(auth) # Provider is the customer name if in loadbalanced config mode provider = auth['provider'] == "bn_launcher" ? auth['info']['customer'] : auth['provider'] - u = find_by(social_uid: auth['uid'], provider: provider) - - if ENV["MAINTENANCE_MODE"] == "readonly" - raise ActiveRecord::ReadOnlyRecord if u.nil? - - return u + find_or_initialize_by(social_uid: auth['uid'], provider: provider).tap do |u| + 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) + u.email_verified = true + u.save! 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) - u.email_verified = true - u.save! - u end private diff --git a/bin/start b/bin/start index b5d475d2..2bcb8ca1 100755 --- a/bin/start +++ b/bin/start @@ -10,10 +10,8 @@ fi bundle exec rake db:create -if [ "$MAINTENANCE_MODE" != "readonly" ] && [ "$MAINTENANCE_MODE" != "full" ]; then - if ! bundle exec rake db:migrate ; then - export DB_MIGRATE_FAILED=1 - fi +if ! bundle exec rake db:migrate ; then + export DB_MIGRATE_FAILED=1 fi bundle exec rake assets:precompile diff --git a/config/locales/en.yml b/config/locales/en.yml index 8434beb5..2bedb799 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -124,7 +124,6 @@ en: maintenance: message: Sorry, we're down for maintenance. help: We'll be back soon! - readonly: This application is under maintenance. You will not be able to perform this action migration_error: contact_admin: If you are not an administrator, please contact one. continue: I'd like to stay using 1.0. diff --git a/sample.env b/sample.env index c69304b6..d030d3c0 100644 --- a/sample.env +++ b/sample.env @@ -147,8 +147,7 @@ ENABLE_GOOGLE_CALENDAR_BUTTON= # Set the application into Maintenance Mode # # Current options supported: -# full: 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 +# true: Renders an error page that does not allow users to access any of the features in the application # false: Application runs normally MAINTENANCE_MODE=false