闭社主体 forked from https://github.com/tootsuite/mastodon
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.

44 lines
1022 B

  1. # frozen_string_literal: true
  2. class Auth::RegistrationsController < Devise::RegistrationsController
  3. layout :determine_layout
  4. before_action :check_enabled_registrations, only: [:new, :create]
  5. before_action :configure_sign_up_params, only: [:create]
  6. def destroy
  7. not_found
  8. end
  9. protected
  10. def build_resource(hash = nil)
  11. super(hash)
  12. resource.locale = I18n.locale
  13. resource.build_account if resource.account.nil?
  14. end
  15. def configure_sign_up_params
  16. devise_parameter_sanitizer.permit(:sign_up) do |u|
  17. u.permit({ account_attributes: [:username] }, :email, :password, :password_confirmation)
  18. end
  19. end
  20. def after_sign_up_path_for(_resource)
  21. new_user_session_path
  22. end
  23. def after_inactive_sign_up_path_for(_resource)
  24. new_user_session_path
  25. end
  26. def check_enabled_registrations
  27. redirect_to root_path if single_user_mode? || !Setting.open_registrations
  28. end
  29. private
  30. def determine_layout
  31. %w(edit update).include?(action_name) ? 'admin' : 'auth'
  32. end
  33. end