confirmations_controller.rb 900 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # frozen_string_literal: true
  2. class Auth::ConfirmationsController < Devise::ConfirmationsController
  3. layout 'auth'
  4. before_action :set_body_classes
  5. before_action :set_user, only: [:finish_signup]
  6. def finish_signup
  7. return unless request.patch? && params[:user]
  8. if @user.update(user_params)
  9. @user.skip_reconfirmation!
  10. bypass_sign_in(@user)
  11. redirect_to root_path, notice: I18n.t('devise.confirmations.send_instructions')
  12. else
  13. @show_errors = true
  14. end
  15. end
  16. private
  17. def set_user
  18. @user = current_user
  19. end
  20. def set_body_classes
  21. @body_classes = 'lighter'
  22. end
  23. def user_params
  24. params.require(:user).permit(:email)
  25. end
  26. def after_confirmation_path_for(_resource_name, user)
  27. if user.created_by_application && truthy_param?(:redirect_to_app)
  28. user.created_by_application.redirect_uri
  29. else
  30. super
  31. end
  32. end
  33. end