Class: Kaui::RegistrationsController

Inherits:
Devise::RegistrationsController
  • Object
show all
Defined in:
app/controllers/kaui/registrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/kaui/registrations_controller.rb', line 8

def create

  if Kaui.
    flash[:error] = 'You need to sign in before adding a user!'
    redirect_to new_user_session_path and return
  end

   = 

  @user = Kaui::AllowedUser.new(:kb_username => .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!(.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