From 4bb2f1b7454e8e0efa29dea1fb4c78e15e441586 Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Thu, 11 Feb 2021 01:18:36 -0500 Subject: [PATCH] Verification requests should use the writing role --- .../verifications/moderation_controller.rb | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/controllers/settings/verifications/moderation_controller.rb b/app/controllers/settings/verifications/moderation_controller.rb index 7bdb8e57..d18c272d 100644 --- a/app/controllers/settings/verifications/moderation_controller.rb +++ b/app/controllers/settings/verifications/moderation_controller.rb @@ -4,26 +4,31 @@ class Settings::Verifications::ModerationController < Admin::BaseController end def approve - verification_request = AccountVerificationRequest.find(params[:id]) - - # Mark user as verified - account = verification_request.account - account.is_verified = true - account.save() + + ActiveRecord::Base.connected_to(role: :writing) do + verification_request = AccountVerificationRequest.find(params[:id]) + + # Mark user as verified + account = verification_request.account + account.is_verified = true + account.save() + + # Remove all traces + verification_request.destroy() + end # Notify user UserMailer.verification_approved(account.user).deliver_later! - # Remove all traces - verification_request.destroy() - # Redirect back to the form with a proper message redirect_to settings_verifications_moderation_url, notice: I18n.t('verifications.moderation.approved_msg') end def reject - verification_request = AccountVerificationRequest.find(params[:id]) - verification_request.destroy() + ActiveRecord::Base.connected_to(role: :writing) do + verification_request = AccountVerificationRequest.find(params[:id]) + verification_request.destroy() + end redirect_to settings_verifications_moderation_url, notice: I18n.t('verifications.moderation.rejected_msg') end end