blob: bdbb7b00c403a454f28ab15bfb1aa6e7a3ef4064 (
plain)
1
2
3
4
5
6
7
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# frozen_string_literal: true
module Registrations
class WelcomeController < ApplicationController
include OneTrustCSP
include GoogleAnalyticsCSP
include GoogleSyndicationCSP
include ::Gitlab::Utils::StrongMemoize
include Onboarding::Redirectable
layout 'minimal'
# TODO: Once this is an ee + SaaS only feature, we can remove this.
# To be completed in https://gitlab.com/gitlab-org/gitlab/-/issues/411858
skip_before_action :check_two_factor_requirement
helper_method :welcome_update_params
helper_method :onboarding_status
feature_category :user_management
def show
return redirect_to path_for_signed_in_user if completed_welcome_step?
track_event('render')
end
def update
result = ::Users::SignupService.new(current_user, update_params).execute
if result.success?
track_event('successfully_submitted_form')
successful_update_hooks
redirect_to update_success_path
else
render :show
end
end
private
def authenticate_user!
return if current_user
redirect_to new_user_registration_path
end
def completed_welcome_step?
!current_user.setup_for_company.nil?
end
def update_params
params.require(:user).permit(:role, :setup_for_company)
end
def update_success_path
if onboarding_status.continue_full_onboarding? # trials/regular registration on .com
signup_onboarding_path
elsif onboarding_status.single_invite? # invites w/o tasks due to order
flash[:notice] = helpers.invite_accepted_notice(onboarding_status.last_invited_member)
onboarding_status.last_invited_member_source.activity_path
else
# Subscription registrations goes through here as well.
# Invites will come here too if there is more than 1.
path_for_signed_in_user
end
end
# overridden in EE
def successful_update_hooks; end
# overridden in EE
def signup_onboarding_path; end
# overridden in EE
def track_event(action); end
# overridden in EE
def welcome_update_params
{}
end
def onboarding_status
Onboarding::Status.new(params.to_unsafe_h.deep_symbolize_keys, session, current_user)
end
strong_memoize_attr :onboarding_status
end
end
Registrations::WelcomeController.prepend_mod_with('Registrations::WelcomeController')
|