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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
a6ba8647
Commit
a6ba8647
authored
Apr 19, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve uniqueness of field names on the signup form
Closes
https://gitlab.com/gitlab-org/gitlab-ce/issues/15075
parent
6a19467c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
22 deletions
+29
-22
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+7
-0
app/views/devise/shared/_signup_box.html.haml
app/views/devise/shared/_signup_box.html.haml
+2
-2
spec/features/signup_spec.rb
spec/features/signup_spec.rb
+12
-12
spec/features/users_spec.rb
spec/features/users_spec.rb
+8
-8
No files found.
app/controllers/registrations_controller.rb
View file @
a6ba8647
...
@@ -8,6 +8,13 @@ class RegistrationsController < Devise::RegistrationsController
...
@@ -8,6 +8,13 @@ class RegistrationsController < Devise::RegistrationsController
def
create
def
create
if
!
Gitlab
::
Recaptcha
.
load_configurations!
||
verify_recaptcha
if
!
Gitlab
::
Recaptcha
.
load_configurations!
||
verify_recaptcha
# To avoid duplicate form fields on the login page, the registration form
# names fields using `new_user`, but Devise still wants the params in
# `user`.
if
params
[
"new_
#{
resource_name
}
"
].
present?
&&
params
[
resource_name
].
blank?
params
[
resource_name
]
=
params
.
delete
(
:"new_
#{
resource_name
}
"
)
end
super
super
else
else
flash
[
:alert
]
=
"There was an error with the reCAPTCHA code below. Please re-enter the code."
flash
[
:alert
]
=
"There was an error with the reCAPTCHA code below. Please re-enter the code."
...
...
app/views/devise/shared/_signup_box.html.haml
View file @
a6ba8647
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
.login-heading
.login-heading
%h3
Create an account
%h3
Create an account
.login-body
.login-body
=
form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
))
do
|
f
|
=
form_for
(
resource
,
as:
"new_
#{
resource_name
}
"
,
url:
registration_path
(
resource_name
))
do
|
f
|
.devise-errors
.devise-errors
=
devise_error_messages!
=
devise_error_messages!
%div
%div
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
%div
%div
=
f
.
email_field
:email
,
class:
"form-control middle"
,
placeholder:
"Email"
,
required:
true
=
f
.
email_field
:email
,
class:
"form-control middle"
,
placeholder:
"Email"
,
required:
true
.form-group.append-bottom-20
#password-strength
.form-group.append-bottom-20
#password-strength
=
f
.
password_field
:password
,
class:
"form-control bottom"
,
id:
"user_password_sign_up"
,
placeholder:
"Password"
,
required:
true
=
f
.
password_field
:password
,
class:
"form-control bottom"
,
placeholder:
"Password"
,
required:
true
%div
%div
-
if
current_application_settings
.
recaptcha_enabled
-
if
current_application_settings
.
recaptcha_enabled
=
recaptcha_tags
=
recaptcha_tags
...
...
spec/features/signup_spec.rb
View file @
a6ba8647
...
@@ -7,10 +7,10 @@ feature 'Signup', feature: true do
...
@@ -7,10 +7,10 @@ feature 'Signup', feature: true do
visit
root_path
visit
root_path
fill_in
'
user_name'
,
with:
user
.
name
fill_in
'
new_user_name'
,
with:
user
.
name
fill_in
'
user_username'
,
with:
user
.
username
fill_in
'
new_user_username'
,
with:
user
.
username
fill_in
'
user_email'
,
with:
user
.
email
fill_in
'
new_user_email'
,
with:
user
.
email
fill_in
'
user_password_sign_up'
,
with:
user
.
password
fill_in
'
new_user_password'
,
with:
user
.
password
click_button
"Sign up"
click_button
"Sign up"
expect
(
current_path
).
to
eq
user_session_path
expect
(
current_path
).
to
eq
user_session_path
...
@@ -25,10 +25,10 @@ feature 'Signup', feature: true do
...
@@ -25,10 +25,10 @@ feature 'Signup', feature: true do
visit
root_path
visit
root_path
fill_in
'
user_name'
,
with:
user
.
name
fill_in
'
new_user_name'
,
with:
user
.
name
fill_in
'
user_username'
,
with:
user
.
username
fill_in
'
new_user_username'
,
with:
user
.
username
fill_in
'
user_email'
,
with:
existing_user
.
email
fill_in
'
new_user_email'
,
with:
existing_user
.
email
fill_in
'
user_password_sign_up'
,
with:
user
.
password
fill_in
'
new_user_password'
,
with:
user
.
password
click_button
"Sign up"
click_button
"Sign up"
expect
(
current_path
).
to
eq
user_registration_path
expect
(
current_path
).
to
eq
user_registration_path
...
@@ -42,10 +42,10 @@ feature 'Signup', feature: true do
...
@@ -42,10 +42,10 @@ feature 'Signup', feature: true do
visit
root_path
visit
root_path
fill_in
'
user_name'
,
with:
user
.
name
fill_in
'
new_user_name'
,
with:
user
.
name
fill_in
'
user_username'
,
with:
user
.
username
fill_in
'
new_user_username'
,
with:
user
.
username
fill_in
'
user_email'
,
with:
existing_user
.
email
fill_in
'
new_user_email'
,
with:
existing_user
.
email
fill_in
'
user_password_sign_up'
,
with:
user
.
password
fill_in
'
new_user_password'
,
with:
user
.
password
click_button
"Sign up"
click_button
"Sign up"
expect
(
current_path
).
to
eq
user_registration_path
expect
(
current_path
).
to
eq
user_registration_path
...
...
spec/features/users_spec.rb
View file @
a6ba8647
...
@@ -5,10 +5,10 @@ feature 'Users', feature: true do
...
@@ -5,10 +5,10 @@ feature 'Users', feature: true do
scenario
'GET /users/sign_in creates a new user account'
do
scenario
'GET /users/sign_in creates a new user account'
do
visit
new_user_session_path
visit
new_user_session_path
fill_in
'
user_name'
,
with:
'Name Surname'
fill_in
'
new_user_name'
,
with:
'Name Surname'
fill_in
'user_username'
,
with:
'Great'
fill_in
'
new_
user_username'
,
with:
'Great'
fill_in
'
user_email'
,
with:
'name@mail.com'
fill_in
'
new_user_email'
,
with:
'name@mail.com'
fill_in
'
user_password_sign_up
'
,
with:
'password1234'
fill_in
'
new_user_password
'
,
with:
'password1234'
expect
{
click_button
'Sign up'
}.
to
change
{
User
.
count
}.
by
(
1
)
expect
{
click_button
'Sign up'
}.
to
change
{
User
.
count
}.
by
(
1
)
end
end
...
@@ -31,10 +31,10 @@ feature 'Users', feature: true do
...
@@ -31,10 +31,10 @@ feature 'Users', feature: true do
scenario
'Should show one error if email is already taken'
do
scenario
'Should show one error if email is already taken'
do
visit
new_user_session_path
visit
new_user_session_path
fill_in
'
user_name'
,
with:
'Another user name'
fill_in
'
new_user_name'
,
with:
'Another user name'
fill_in
'user_username'
,
with:
'anotheruser'
fill_in
'
new_
user_username'
,
with:
'anotheruser'
fill_in
'
user_email'
,
with:
user
.
email
fill_in
'
new_user_email'
,
with:
user
.
email
fill_in
'
user_password_sign_up
'
,
with:
'12341234'
fill_in
'
new_user_password
'
,
with:
'12341234'
expect
{
click_button
'Sign up'
}.
to
change
{
User
.
count
}.
by
(
0
)
expect
{
click_button
'Sign up'
}.
to
change
{
User
.
count
}.
by
(
0
)
expect
(
page
).
to
have_text
(
'Email has already been taken'
)
expect
(
page
).
to
have_text
(
'Email has already been taken'
)
expect
(
number_of_errors_on_page
(
page
)).
to
be
(
1
),
'errors on page:\n #{errors_on_page page}'
expect
(
number_of_errors_on_page
(
page
)).
to
be
(
1
),
'errors on page:\n #{errors_on_page page}'
...
...
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