Sha256: 19dcd4b0ea4db9b6431bdb1d54608e8331bd26977969ddb8d422610a61a75c13

Contents?: true

Size: 1.17 KB

Versions: 10

Compression:

Stored size: 1.17 KB

Contents

module Kaui
  class RegistrationsController < Devise::RegistrationsController
    layout Kaui.config[:layout]

    skip_before_filter :check_for_redirect_to_tenant_screen

    def create
      @user = Kaui::AllowedUser.new(:kb_username => sign_up_params.require(:kb_username))

      if Kaui::AllowedUser.find_by_kb_username(@user.kb_username).present?
        flash.now[:error] = "User with name #{@user.kb_username} already exists!"
        render :new and return
      end

      # Create locally and in KB
      @user.create_in_kb!(sign_up_params.require(:password),
                          Kaui.default_roles,
                          'Kaui::RegistrationsController',
                          params[:reason],
                          params[:comment],
                          root_options_for_klient)

      flash[:notice] = "User #{@user.kb_username} successfully created, please login"
      redirect_to new_user_session_path
    end

    private

    def root_options_for_klient
      {
          :username => Kaui.root_username,
          :password => Kaui.root_password,
          :api_key => Kaui.root_api_key,
          :api_secret => Kaui.root_api_secret
      }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kaui-0.15.5 app/controllers/kaui/registrations_controller.rb
kaui-0.15.4 app/controllers/kaui/registrations_controller.rb
kaui-0.15.3 app/controllers/kaui/registrations_controller.rb
kaui-0.15.2 app/controllers/kaui/registrations_controller.rb
kaui-0.15.1 app/controllers/kaui/registrations_controller.rb
kaui-0.15.0 app/controllers/kaui/registrations_controller.rb
kaui-0.14.2 app/controllers/kaui/registrations_controller.rb
kaui-0.14.1 app/controllers/kaui/registrations_controller.rb
kaui-0.14.0 app/controllers/kaui/registrations_controller.rb
kaui-0.12.0 app/controllers/kaui/registrations_controller.rb