feat: Add Installation onboarding flow (#1640)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -3,6 +3,7 @@ class DashboardController < ActionController::Base
|
||||
|
||||
before_action :set_global_config
|
||||
around_action :switch_locale
|
||||
before_action :ensure_installation_onboarding, only: [:index]
|
||||
|
||||
layout 'vueapp'
|
||||
|
||||
@@ -24,4 +25,8 @@ class DashboardController < ActionController::Base
|
||||
APP_VERSION: Chatwoot.config[:version]
|
||||
)
|
||||
end
|
||||
|
||||
def ensure_installation_onboarding
|
||||
redirect_to '/installation/onboarding' if ::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
|
||||
end
|
||||
end
|
||||
|
||||
36
app/controllers/installation/onboarding_controller.rb
Normal file
36
app/controllers/installation/onboarding_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Installation::OnboardingController < ApplicationController
|
||||
before_action :ensure_installation_onboarding
|
||||
|
||||
def index; end
|
||||
|
||||
def create
|
||||
begin
|
||||
AccountBuilder.new(
|
||||
account_name: onboarding_params.dig(:user, :company),
|
||||
user_full_name: onboarding_params.dig(:user, :name),
|
||||
email: onboarding_params.dig(:user, :email),
|
||||
user_password: params.dig(:user, :password),
|
||||
confirmed: true
|
||||
).perform
|
||||
rescue StandardError => e
|
||||
redirect_to '/', flash: { error: e.message } and return
|
||||
end
|
||||
finish_onboarding
|
||||
redirect_to '/'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def onboarding_params
|
||||
params.permit(:subscribe_to_updates, user: [:name, :company, :email])
|
||||
end
|
||||
|
||||
def finish_onboarding
|
||||
::Redis::Alfred.delete(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
|
||||
ChatwootHub.register_instance(onboarding_params) if onboarding_params[:subscribe_to_updates]
|
||||
end
|
||||
|
||||
def ensure_installation_onboarding
|
||||
redirect_to '/' unless ::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user