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.

47 lines
968 B

  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. before_action :set_pack
  7. def finish_signup
  8. return unless request.patch? && params[:user]
  9. if @user.update(user_params)
  10. @user.skip_reconfirmation!
  11. bypass_sign_in(@user)
  12. redirect_to root_path, notice: I18n.t('devise.confirmations.send_instructions')
  13. else
  14. @show_errors = true
  15. end
  16. end
  17. private
  18. def set_pack
  19. use_pack 'auth'
  20. end
  21. def set_user
  22. @user = current_user
  23. end
  24. def set_body_classes
  25. @body_classes = 'lighter'
  26. end
  27. def user_params
  28. params.require(:user).permit(:email)
  29. end
  30. def after_confirmation_path_for(_resource_name, user)
  31. if user.created_by_application && truthy_param?(:redirect_to_app)
  32. user.created_by_application.redirect_uri
  33. else
  34. super
  35. end
  36. end
  37. end