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
d2b6122b
Commit
d2b6122b
authored
Mar 30, 2021
by
Doug Stull
Committed by
Stan Hu
Mar 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect invitation acceptance to sign-up when valid
- allows better user experience.
parent
4e7dd083
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
123 additions
and
20 deletions
+123
-20
app/controllers/invites_controller.rb
app/controllers/invites_controller.rb
+20
-6
app/views/devise/shared/_sign_in_link.html.haml
app/views/devise/shared/_sign_in_link.html.haml
+3
-1
changelogs/unreleased/325288-send-invited-users-to-correct-page-sign-in-or-sign-up.yml
...send-invited-users-to-correct-page-sign-in-or-sign-up.yml
+5
-0
ee/spec/features/invites_spec.rb
ee/spec/features/invites_spec.rb
+0
-1
locale/gitlab.pot
locale/gitlab.pot
+9
-0
spec/controllers/invites_controller_spec.rb
spec/controllers/invites_controller_spec.rb
+77
-4
spec/features/invites_spec.rb
spec/features/invites_spec.rb
+9
-8
No files found.
app/controllers/invites_controller.rb
View file @
d2b6122b
...
...
@@ -91,15 +91,29 @@ class InvitesController < ApplicationController
def
authenticate_user!
return
if
current_user
notice
=
[
"To accept this invitation, sign in"
]
notice
<<
"or create an account"
if
Gitlab
::
CurrentSettings
.
allow_signup?
notice
=
notice
.
join
(
' '
)
+
"."
store_location_for
:user
,
request
.
fullpath
redirect_params
=
member
?
{
invite_email:
member
.
invite_email
}
:
{}
if
user_sign_up?
redirect_to
new_user_registration_path
(
invite_email:
member
.
invite_email
),
notice:
_
(
"To accept this invitation, create an account or sign in."
)
else
redirect_to
new_user_session_path
(
sign_in_redirect_params
),
notice:
sign_in_notice
end
end
store_location_for
:user
,
request
.
fullpath
def
sign_in_redirect_params
member
?
{
invite_email:
member
.
invite_email
}
:
{}
end
def
user_sign_up?
Gitlab
::
CurrentSettings
.
allow_signup?
&&
member
&&
!
User
.
find_by_any_email
(
member
.
invite_email
)
end
redirect_to
new_user_session_path
(
redirect_params
),
notice:
notice
def
sign_in_notice
if
Gitlab
::
CurrentSettings
.
allow_signup?
_
(
"To accept this invitation, sign in or create an account."
)
else
_
(
"To accept this invitation, sign in."
)
end
end
def
invite_details
...
...
app/views/devise/shared/_sign_in_link.html.haml
View file @
d2b6122b
%p
.text-center
%span
.light
Already have login and password?
=
link_to
"Sign in"
,
new_session_path
(
:user
,
redirect_to_referer:
'yes'
)
-
path_params
=
{
redirect_to_referer:
'yes'
}
-
path_params
[
:invite_email
]
=
@invite_email
if
@invite_email
.
present?
=
link_to
"Sign in"
,
new_session_path
(
:user
,
path_params
)
changelogs/unreleased/325288-send-invited-users-to-correct-page-sign-in-or-sign-up.yml
0 → 100644
View file @
d2b6122b
---
title
:
Send invited users to sign up instead of sign in when possible
merge_request
:
57240
author
:
type
:
other
ee/spec/features/invites_spec.rb
View file @
d2b6122b
...
...
@@ -14,7 +14,6 @@ RSpec.describe 'Group or Project invitations' do
allow
(
::
Gitlab
).
to
receive
(
:dev_env_or_com?
).
and_return
(
dev_env_or_com
)
visit
invite_path
(
group_invite
.
raw_invite_token
)
click_link
'Register now'
end
def
fill_in_sign_up_form
(
user
)
...
...
locale/gitlab.pot
View file @
d2b6122b
...
...
@@ -31792,6 +31792,15 @@ msgstr ""
msgid "To GitLab"
msgstr ""
msgid "To accept this invitation, create an account or sign in."
msgstr ""
msgid "To accept this invitation, sign in or create an account."
msgstr ""
msgid "To accept this invitation, sign in."
msgstr ""
msgid "To access this domain create a new DNS record"
msgstr ""
...
...
spec/controllers/invites_controller_spec.rb
View file @
d2b6122b
...
...
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec
.
describe
InvitesController
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:member
)
{
create
(
:project_member
,
:invited
,
invite_email:
user
.
email
)
}
let
_it_be
(
:member
,
reload:
true
)
{
create
(
:project_member
,
:invited
,
invite_email:
user
.
email
)
}
let
(
:raw_invite_token
)
{
member
.
raw_invite_token
}
let
(
:project_members
)
{
member
.
source
.
users
}
let
(
:md5_member_global_id
)
{
Digest
::
MD5
.
hexdigest
(
member
.
to_global_id
.
to_s
)
}
...
...
@@ -77,10 +77,83 @@ RSpec.describe InvitesController do
context
'when not logged in'
do
context
'when inviter is a member'
do
it
'is redirected to a new session with invite email param'
do
request
context
'when instance allows sign up'
do
it
'indicates an account can be created in notice'
do
request
expect
(
flash
[
:notice
]).
to
include
(
'or create an account'
)
end
context
'when user exists with the invited email'
do
it
'is redirected to a new session with invite email param'
do
request
expect
(
response
).
to
redirect_to
(
new_user_session_path
(
invite_email:
member
.
invite_email
))
end
end
context
'when user exists with the invited email as secondary email'
do
before
do
secondary_email
=
create
(
:email
,
user:
user
,
email:
'foo@example.com'
)
member
.
update!
(
invite_email:
secondary_email
.
email
)
end
it
'is redirected to a new session with invite email param'
do
request
expect
(
response
).
to
redirect_to
(
new_user_session_path
(
invite_email:
member
.
invite_email
))
end
end
context
'when user does not exist with the invited email'
do
before
do
member
.
update!
(
invite_email:
'bogus_email@example.com'
)
end
it
'indicates an account can be created in notice'
do
request
expect
(
flash
[
:notice
]).
to
include
(
'create an account or sign in'
)
end
it
'is redirected to a new registration with invite email param'
do
request
expect
(
response
).
to
redirect_to
(
new_user_registration_path
(
invite_email:
member
.
invite_email
))
end
end
end
context
'when instance does not allow sign up'
do
before
do
stub_application_setting
(
allow_signup?:
false
)
end
it
'does not indicate an account can be created in notice'
do
request
expect
(
flash
[
:notice
]).
not_to
include
(
'or create an account'
)
end
context
'when user exists with the invited email'
do
it
'is redirected to a new session with invite email param'
do
request
expect
(
response
).
to
redirect_to
(
new_user_session_path
(
invite_email:
member
.
invite_email
))
end
end
context
'when user does not exist with the invited email'
do
before
do
member
.
update!
(
invite_email:
'bogus_email@example.com'
)
end
it
'is redirected to a new session with invite email param'
do
request
expect
(
response
).
to
redirect_to
(
new_user_session_path
(
invite_email:
member
.
invite_email
))
expect
(
response
).
to
redirect_to
(
new_user_session_path
(
invite_email:
member
.
invite_email
))
end
end
end
end
...
...
spec/features/invites_spec.rb
View file @
d2b6122b
...
...
@@ -50,21 +50,23 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do
end
it
'renders sign in page with sign in notice'
do
expect
(
current_path
).
to
eq
(
new_user_
sess
ion_path
)
expect
(
page
).
to
have_content
(
'To accept this invitation, sign in'
)
expect
(
current_path
).
to
eq
(
new_user_
registrat
ion_path
)
expect
(
page
).
to
have_content
(
'To accept this invitation,
create an account or
sign in'
)
end
it
'pre-fills the "Username or email" field on the sign in box with the invite_email from the invite'
do
click_link
'Sign in'
expect
(
find_field
(
'Username or email'
).
value
).
to
eq
(
group_invite
.
invite_email
)
end
it
'pre-fills the Email field on the sign up box with the invite_email from the invite'
do
click_link
'Register now'
expect
(
find_field
(
'Email'
).
value
).
to
eq
(
group_invite
.
invite_email
)
end
it
'sign in, grants access and redirects to group page'
do
click_link
'Sign in'
fill_in_sign_in_form
(
user
)
expect
(
current_path
).
to
eq
(
group_path
(
group
))
...
...
@@ -85,20 +87,19 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures do
end
end
context
'when inviting a user'
do
context
'when inviting a
n unregistered
user'
do
let
(
:new_user
)
{
build_stubbed
(
:user
)
}
let
(
:invite_email
)
{
new_user
.
email
}
let
(
:group_invite
)
{
create
(
:group_member
,
:invited
,
group:
group
,
invite_email:
invite_email
,
created_by:
owner
)
}
let!
(
:project_invite
)
{
create
(
:project_member
,
:invited
,
project:
project
,
invite_email:
invite_email
)
}
context
'when
user has not signed in yet
'
do
context
'when
registering using invitation email
'
do
before
do
stub_application_setting
(
send_user_confirmation_email:
send_email_confirmation
)
visit
invite_path
(
group_invite
.
raw_invite_token
)
click_link
'Register now'
end
context
'with admin appoval required enabled'
do
context
'with admin app
r
oval required enabled'
do
before
do
stub_application_setting
(
require_admin_approval_after_user_signup:
true
)
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