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
Léo-Paul Géneau
gitlab-ce
Commits
71ca2de7
Commit
71ca2de7
authored
Apr 21, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toggle email signup confirmation in admin settings
parent
78a67fc4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
0 deletions
+54
-0
CHANGELOG
CHANGELOG
+1
-0
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+1
-0
app/models/user.rb
app/models/user.rb
+5
-0
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+6
-0
db/migrate/20160421141709_add_skip_confirmation_email_to_application_settings.rb
...09_add_skip_confirmation_email_to_application_settings.rb
+8
-0
spec/controllers/registrations_controller_spec.rb
spec/controllers/registrations_controller_spec.rb
+33
-0
No files found.
CHANGELOG
View file @
71ca2de7
...
@@ -189,6 +189,7 @@ v 8.7.0
...
@@ -189,6 +189,7 @@ v 8.7.0
- Add Slack notifications when Wiki is edited (Sebastian Klier)
- Add Slack notifications when Wiki is edited (Sebastian Klier)
- Diffs load at the correct point when linking from from number
- Diffs load at the correct point when linking from from number
- Selected diff rows highlight
- Selected diff rows highlight
- Toggle sign-up confirmation emails in application settings
- Fix emoji categories in the emoji picker
- Fix emoji categories in the emoji picker
- API: Properly display annotated tags for GET /projects/:id/repository/tags (Robert Schilling)
- API: Properly display annotated tags for GET /projects/:id/repository/tags (Robert Schilling)
- Add encrypted credentials for imported projects and migrate old ones
- Add encrypted credentials for imported projects and migrate old ones
...
...
app/controllers/admin/application_settings_controller.rb
View file @
71ca2de7
...
@@ -106,6 +106,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
...
@@ -106,6 +106,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:email_author_in_body
,
:email_author_in_body
,
:repository_checks_enabled
,
:repository_checks_enabled
,
:metrics_packet_size
,
:metrics_packet_size
,
:skip_user_confirmation_email
,
restricted_visibility_levels:
[],
restricted_visibility_levels:
[],
import_sources:
[],
import_sources:
[],
disabled_oauth_sign_in_sources:
[]
disabled_oauth_sign_in_sources:
[]
...
...
app/models/user.rb
View file @
71ca2de7
...
@@ -112,6 +112,7 @@ class User < ActiveRecord::Base
...
@@ -112,6 +112,7 @@ class User < ActiveRecord::Base
before_save
:ensure_external_user_rights
before_save
:ensure_external_user_rights
after_save
:ensure_namespace_correct
after_save
:ensure_namespace_correct
after_initialize
:set_projects_limit
after_initialize
:set_projects_limit
before_create
:check_confirmation_email
after_create
:post_create_hook
after_create
:post_create_hook
after_destroy
:post_destroy_hook
after_destroy
:post_destroy_hook
...
@@ -307,6 +308,10 @@ class User < ActiveRecord::Base
...
@@ -307,6 +308,10 @@ class User < ActiveRecord::Base
@reset_token
@reset_token
end
end
def
check_confirmation_email
skip_confirmation!
if
current_application_settings
.
skip_user_confirmation_email
end
def
recently_sent_password_reset?
def
recently_sent_password_reset?
reset_password_sent_at
.
present?
&&
reset_password_sent_at
>=
1
.
minute
.
ago
reset_password_sent_at
.
present?
&&
reset_password_sent_at
>=
1
.
minute
.
ago
end
end
...
...
app/views/admin/application_settings/_form.html.haml
View file @
71ca2de7
...
@@ -103,6 +103,12 @@
...
@@ -103,6 +103,12 @@
=
f
.
label
:signup_enabled
do
=
f
.
label
:signup_enabled
do
=
f
.
check_box
:signup_enabled
=
f
.
check_box
:signup_enabled
Sign-up enabled
Sign-up enabled
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
=
f
.
label
:skip_confirmation_email
do
=
f
.
check_box
:skip_user_confirmation_email
Skip sign-up email confirmation
.form-group
.form-group
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
.checkbox
.checkbox
...
...
db/migrate/20160421141709_add_skip_confirmation_email_to_application_settings.rb
0 → 100644
View file @
71ca2de7
class
AddSkipConfirmationEmailToApplicationSettings
<
ActiveRecord
::
Migration
def
change
#Skip confirmation emails just for new installations
default_value
=
User
.
count
>
0
?
false
:
true
add_column
:application_settings
,
:skip_user_confirmation_email
,
:boolean
,
default:
default_value
end
end
spec/controllers/registrations_controller_spec.rb
0 → 100644
View file @
71ca2de7
require
'spec_helper'
describe
RegistrationsController
do
describe
'#create'
do
around
(
:each
)
do
|
example
|
perform_enqueued_jobs
do
example
.
run
end
end
let
(
:user_params
)
{
{
"user"
=>
{
"name"
=>
"new_user"
,
"username"
=>
"new_username"
,
"email"
=>
"new@user.com"
,
"password"
=>
"Any_password"
}
}
}
context
'when skipping email confirmation'
do
before
{
allow
(
current_application_settings
).
to
receive
(
:skip_user_confirmation_email
).
and_return
(
true
)
}
it
'logs user in directly'
do
post
(
:create
,
user_params
)
expect
(
ActionMailer
::
Base
.
deliveries
.
last
).
to
be_nil
expect
(
subject
.
current_user
).
to
be
end
end
context
'when not skipping email confirmation'
do
before
{
allow
(
current_application_settings
).
to
receive
(
:skip_user_confirmation_email
).
and_return
(
false
)
}
it
'does not authenticate user and sends confirmation email'
do
post
(
:create
,
user_params
)
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
to
.
first
).
to
eq
(
user_params
[
"user"
][
"email"
])
expect
(
subject
.
current_user
).
to
be_nil
end
end
end
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