2019-07-02 08:10:25 +01:00
|
|
|
class Settings::Verifications::ModerationController < Admin::BaseController
|
|
|
|
def index
|
2020-12-16 00:31:30 +00:00
|
|
|
@verification_requests = AccountVerificationRequest.order('created_at DESC').all
|
2019-07-02 08:10:25 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def approve
|
2021-02-11 06:18:36 +00:00
|
|
|
|
|
|
|
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
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
# Notify user
|
|
|
|
UserMailer.verification_approved(account.user).deliver_later!
|
|
|
|
|
|
|
|
# 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
|
2021-02-11 06:18:36 +00:00
|
|
|
ActiveRecord::Base.connected_to(role: :writing) do
|
|
|
|
verification_request = AccountVerificationRequest.find(params[:id])
|
|
|
|
verification_request.destroy()
|
|
|
|
end
|
2020-12-16 00:31:30 +00:00
|
|
|
redirect_to settings_verifications_moderation_url, notice: I18n.t('verifications.moderation.rejected_msg')
|
2019-07-02 08:10:25 +01:00
|
|
|
end
|
|
|
|
end
|