debian-mirror-gitlab/app/controllers/registrations/welcome_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
2.6 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module Registrations
class WelcomeController < ApplicationController
2022-07-16 23:28:13 +05:30
include OneTrustCSP
2022-08-13 15:12:31 +05:30
include GoogleAnalyticsCSP
2022-07-16 23:28:13 +05:30
2021-09-30 23:02:18 +05:30
layout 'minimal'
2021-01-29 00:20:46 +05:30
skip_before_action :authenticate_user!, :required_signup_info, :check_two_factor_requirement, only: [:show, :update]
before_action :require_current_user
2023-07-09 08:55:56 +05:30
helper_method :welcome_update_params
2023-05-27 22:25:52 +05:30
feature_category :user_management
2021-01-29 00:20:46 +05:30
def show
return redirect_to path_for_signed_in_user(current_user) if completed_welcome_step?
2023-03-04 22:38:38 +05:30
track_event('render')
2021-01-29 00:20:46 +05:30
end
def update
result = ::Users::SignupService.new(current_user, update_params).execute
2023-03-17 16:20:25 +05:30
if result.success?
2023-03-04 22:38:38 +05:30
track_event('successfully_submitted_form')
2023-03-17 16:20:25 +05:30
redirect_to update_success_path
2021-01-29 00:20:46 +05:30
else
render :show
end
end
private
2022-11-25 23:54:43 +05:30
def registering_from_invite?(members)
members.count == 1 && members.last.source.present?
end
2021-01-29 00:20:46 +05:30
def require_current_user
return redirect_to new_user_registration_path unless current_user
end
def completed_welcome_step?
current_user.role.present? && !current_user.setup_for_company.nil?
end
def update_params
2022-07-23 23:45:48 +05:30
params.require(:user).permit(:role, :setup_for_company)
2021-01-29 00:20:46 +05:30
end
def path_for_signed_in_user(user)
2021-06-08 01:23:25 +05:30
stored_location_for(user) || members_activity_path(user.members)
end
def members_activity_path(members)
return dashboard_projects_path unless members.any?
return dashboard_projects_path unless members.last.source.present?
members.last.source.activity_path
2021-01-29 00:20:46 +05:30
end
2021-12-11 22:18:48 +05:30
# overridden in EE
2023-03-17 16:20:25 +05:30
def redirect_to_signup_onboarding?
2021-03-11 19:13:27 +05:30
false
2021-01-29 00:20:46 +05:30
end
2021-10-27 15:23:28 +05:30
2023-03-17 16:20:25 +05:30
def redirect_for_tasks_to_be_done?
2021-12-11 22:18:48 +05:30
MemberTask.for_members(current_user.members).exists?
end
def update_success_path
2023-03-17 16:20:25 +05:30
return issues_dashboard_path(assignee_username: current_user.username) if redirect_for_tasks_to_be_done?
return signup_onboarding_path if redirect_to_signup_onboarding?
members = current_user.members
if registering_from_invite?(members)
flash[:notice] = helpers.invite_accepted_notice(members.last)
members_activity_path(members)
else
# subscription registrations goes through here as well
path_for_signed_in_user(current_user)
end
2021-10-27 15:23:28 +05:30
end
2023-03-04 22:38:38 +05:30
# overridden in EE
2023-03-17 16:20:25 +05:30
def signup_onboarding_path; end
# overridden in EE
def track_event(action); end
2023-07-09 08:55:56 +05:30
# overridden in EE
def welcome_update_params
{}
end
2021-01-29 00:20:46 +05:30
end
end
2021-06-08 01:23:25 +05:30
Registrations::WelcomeController.prepend_mod_with('Registrations::WelcomeController')