registrations_controller.rb 715 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4 5
class Auth::RegistrationsController < Devise::RegistrationsController
  layout 'auth'

Eugen Rochko's avatar
Eugen Rochko committed
6
  before_action :check_single_user_mode
Eugen Rochko's avatar
Eugen Rochko committed
7
  before_action :configure_sign_up_params, only: [:create]
8 9 10 11 12

  protected

  def build_resource(hash = nil)
    super(hash)
Eugen Rochko's avatar
Eugen Rochko committed
13
    resource.build_account if resource.account.nil?
14 15 16
  end

  def configure_sign_up_params
Eugen Rochko's avatar
Eugen Rochko committed
17 18
    devise_parameter_sanitizer.permit(:sign_up) do |u|
      u.permit({ account_attributes: [:username] }, :email, :password, :password_confirmation)
19 20 21
    end
  end

22
  def after_sign_up_path_for(_resource)
23
    new_user_session_path
24
  end
Eugen Rochko's avatar
Eugen Rochko committed
25 26 27 28

  def check_single_user_mode
    redirect_to root_path if Rails.configuration.x.single_user_mode
  end
29
end