1
0

setup_controller.rb 973 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. class Auth::SetupController < ApplicationController
  3. layout 'auth'
  4. before_action :authenticate_user!
  5. before_action :require_unconfirmed_or_pending!
  6. before_action :set_user
  7. skip_before_action :require_functional!
  8. def show; end
  9. def update
  10. # This allows updating the e-mail without entering a password as is required
  11. # on the account settings page; however, we only allow this for accounts
  12. # that were not confirmed yet
  13. if @user.update(user_params)
  14. @user.resend_confirmation_instructions unless @user.confirmed?
  15. redirect_to auth_setup_path, notice: I18n.t('auth.setup.new_confirmation_instructions_sent')
  16. else
  17. render :show
  18. end
  19. end
  20. private
  21. def require_unconfirmed_or_pending!
  22. redirect_to root_path if current_user.confirmed? && current_user.approved?
  23. end
  24. def set_user
  25. @user = current_user
  26. end
  27. def user_params
  28. params.require(:user).permit(:email)
  29. end
  30. end