Commit ca112038 authored by Alex Buijs's avatar Alex Buijs

Require user to have a role

Redirect to the welcome page if a newly signed up
user doesn’t have a role
parent 1e58a809
......@@ -29,6 +29,7 @@ class ApplicationController < ActionController::Base
before_action :active_user_check, unless: :devise_controller?
before_action :set_usage_stats_consent_flag
before_action :check_impersonation_availability
before_action :require_role
around_action :set_locale
around_action :set_session_storage
......@@ -547,6 +548,12 @@ class ApplicationController < ActionController::Base
def current_user_mode
@current_user_mode ||= Gitlab::Auth::CurrentUserMode.new(current_user)
end
def require_role
return unless current_user && current_user.role.blank? && helpers.use_experimental_separate_sign_up_flow?
redirect_to users_sign_up_welcome_path
end
end
ApplicationController.prepend_if_ee('EE::ApplicationController')
......@@ -8,6 +8,7 @@ class RegistrationsController < Devise::RegistrationsController
layout :choose_layout
skip_before_action :require_role, only: [:welcome, :update_role]
prepend_before_action :check_captcha, only: :create
before_action :whitelist_query_limiting, only: [:destroy]
before_action :ensure_terms_accepted,
......
......@@ -6,6 +6,7 @@ FactoryBot.define do
name { generate(:name) }
username { generate(:username) }
password { "12345678" }
role { 'software_developer' }
confirmed_at { Time.now }
confirmation_token { nil }
can_create_group { true }
......
......@@ -401,10 +401,10 @@ describe 'With experimental flow on GitLab.com' do
before do
sign_in(user)
visit users_sign_up_welcome_path
visit root_path
end
it 'is shows step 2 of the signup process' do
it 'is redirected to step 2 of the signup process' do
expect(page).to have_text("Welcome to GitLab.com#{user.username}!")
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment