Class: Postnhost::Onboarding::Steps::CreateAdminAccount

Inherits:
Base show all
Defined in:
app/services/postnhost/onboarding/steps/create_admin_account.rb

Constant Summary

Constants inherited from Base

Base::LANGUAGE_OPTIONS, Base::SITE_COPY_KEYS

Instance Attribute Summary

Attributes inherited from Base

#params, #session

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods inherited from BaseService

call

Constructor Details

This class inherits a constructor from Postnhost::Onboarding::Steps::Base

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/postnhost/onboarding/steps/create_admin_account.rb', line 5

def call
  user = Postnhost::User.new(admin_user_params)

  return success({ alert: "An account already exists." }, status: :redirect_new_session) unless Postnhost::User.none?

  if user.save
    session[:onboarding_pending_user_id] = user.id
    session[:onboarding_step] = 2
    redirect_onboarding
  else
    render_show(step: 1, user:)
  end
end