Class: Workarea::Admin::CreateUsersController

Inherits:
ApplicationController show all
Includes:
UserParams
Defined in:
app/controllers/workarea/admin/create_users_controller.rb

Instance Method Summary collapse

Methods included from UserParams

#user_params

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/workarea/admin/create_users_controller.rb', line 17

def create
  @user.attributes = user_params
  @user.password ||= "#{SecureRandom.hex(20)}_aA1" # extra chars to appease requirements

  if !@user.save
    render_form
  else
    apply_store_credit

    flash[:success] = t('workarea.admin.create_users.flash_messages.created')

    if params[:send_account_creation_email].to_s =~ /true/
      Storefront::AccountMailer.creation(@user.id.to_s).deliver_later
    end

    if !@user.admin? && params[:impersonate].to_s =~ /true/
      impersonate_user(@user)
      redirect_to storefront.
    else
      redirect_to user_path(@user)
    end
  end
end

#indexObject



9
10
11
# File 'app/controllers/workarea/admin/create_users_controller.rb', line 9

def index
  redirect_to new_create_user_path unless current_user.permissions_manager?
end

#newObject



13
14
15
# File 'app/controllers/workarea/admin/create_users_controller.rb', line 13

def new
  render_form
end