confirmations_controller.rb 798 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. module Admin
  3. class ConfirmationsController < BaseController
  4. before_action :set_user
  5. before_action :check_confirmation, only: [:resend]
  6. def create
  7. authorize @user, :confirm?
  8. @user.confirm!
  9. log_action :confirm, @user
  10. redirect_to admin_accounts_path
  11. end
  12. def resend
  13. authorize @user, :confirm?
  14. @user.resend_confirmation_instructions
  15. log_action :resend, @user
  16. flash[:notice] = I18n.t('admin.accounts.resend_confirmation.success')
  17. redirect_to admin_accounts_path
  18. end
  19. private
  20. def check_confirmation
  21. if @user.confirmed?
  22. flash[:error] = I18n.t('admin.accounts.resend_confirmation.already_confirmed')
  23. redirect_to admin_accounts_path
  24. end
  25. end
  26. end
  27. end