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

3 4
class Auth::RegistrationsController < Devise::RegistrationsController
  layout 'auth'
5
  layout 'admin', only: [:edit]
6

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

  protected

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

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

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

27 28 29 30
  def after_inactive_sign_up_path_for(_resource)
    new_user_session_path
  end

Eugen Rochko's avatar
Eugen Rochko committed
31 32 33
  def check_single_user_mode
    redirect_to root_path if Rails.configuration.x.single_user_mode
  end
34
end