setup_controller.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_body_classes
  7. before_action :set_user
  8. skip_before_action :require_functional!
  9. def show; end
  10. def update
  11. # This allows updating the e-mail without entering a password as is required
  12. # on the account settings page; however, we only allow this for accounts
  13. # that were not confirmed yet
  14. if @user.update(user_params)
  15. @user.resend_confirmation_instructions unless @user.confirmed?
  16. redirect_to auth_setup_path, notice: I18n.t('auth.setup.new_confirmation_instructions_sent')
  17. else
  18. render :show
  19. end
  20. end
  21. private
  22. def require_unconfirmed_or_pending!
  23. redirect_to root_path if current_user.confirmed? && current_user.approved?
  24. end
  25. def set_user
  26. @user = current_user
  27. end
  28. def set_body_classes
  29. @body_classes = 'lighter'
  30. end
  31. def user_params
  32. params.require(:user).permit(:email)
  33. end
  34. end