You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
917 B

  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 :confirm, @user
  16. flash[:notice] = I18n.t('admin.accounts.resend_confirmation.success')
  17. redirect_to admin_accounts_path
  18. end
  19. private
  20. def set_user
  21. @user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
  22. end
  23. def check_confirmation
  24. if @user.confirmed?
  25. flash[:error] = I18n.t('admin.accounts.resend_confirmation.already_confirmed')
  26. redirect_to admin_accounts_path
  27. end
  28. end
  29. end
  30. end