Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ca112038
Commit
ca112038
authored
Oct 04, 2019
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require user to have a role
Redirect to the welcome page if a newly signed up user doesn’t have a role
parent
1e58a809
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
2 deletions
+11
-2
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+7
-0
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+1
-0
spec/factories/users.rb
spec/factories/users.rb
+1
-0
spec/features/users/signup_spec.rb
spec/features/users/signup_spec.rb
+2
-2
No files found.
app/controllers/application_controller.rb
View file @
ca112038
...
...
@@ -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'
)
app/controllers/registrations_controller.rb
View file @
ca112038
...
...
@@ -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
,
...
...
spec/factories/users.rb
View file @
ca112038
...
...
@@ -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
}
...
...
spec/features/users/signup_spec.rb
View file @
ca112038
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment