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
158550cf
Commit
158550cf
authored
Jun 16, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added service in the rest of controllers and classes
parent
bf3a3f36
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
12 deletions
+13
-12
app/controllers/profiles/avatars_controller.rb
app/controllers/profiles/avatars_controller.rb
+1
-1
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+3
-3
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
app/services/users/update_service.rb
app/services/users/update_service.rb
+3
-3
lib/api/internal.rb
lib/api/internal.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+2
-2
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+2
-1
No files found.
app/controllers/profiles/avatars_controller.rb
View file @
158550cf
...
@@ -3,7 +3,7 @@ class Profiles::AvatarsController < Profiles::ApplicationController
...
@@ -3,7 +3,7 @@ class Profiles::AvatarsController < Profiles::ApplicationController
@user
=
current_user
@user
=
current_user
@user
.
remove_avatar!
@user
.
remove_avatar!
@user
.
sav
e
Users
::
UpdateService
.
new
(
@user
,
@user
).
execut
e
redirect_to
profile_path
,
status:
302
redirect_to
profile_path
,
status:
302
end
end
...
...
app/controllers/profiles/two_factor_auths_controller.rb
View file @
158550cf
...
@@ -10,7 +10,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
...
@@ -10,7 +10,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
current_user
.
otp_grace_period_started_at
=
Time
.
current
current_user
.
otp_grace_period_started_at
=
Time
.
current
end
end
current_user
.
save!
if
current_user
.
changed?
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute!
if
two_factor_authentication_required?
&&
!
current_user
.
two_factor_enabled?
if
two_factor_authentication_required?
&&
!
current_user
.
two_factor_enabled?
two_factor_authentication_reason
(
two_factor_authentication_reason
(
...
@@ -43,7 +43,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
...
@@ -43,7 +43,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
if
current_user
.
validate_and_consume_otp!
(
params
[
:pin_code
])
if
current_user
.
validate_and_consume_otp!
(
params
[
:pin_code
])
current_user
.
otp_required_for_login
=
true
current_user
.
otp_required_for_login
=
true
@codes
=
current_user
.
generate_otp_backup_codes!
@codes
=
current_user
.
generate_otp_backup_codes!
current_user
.
sav
e!
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execut
e!
render
'create'
render
'create'
else
else
...
@@ -71,7 +71,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
...
@@ -71,7 +71,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
def
codes
def
codes
@codes
=
current_user
.
generate_otp_backup_codes!
@codes
=
current_user
.
generate_otp_backup_codes!
current_user
.
sav
e!
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execut
e!
end
end
def
destroy
def
destroy
...
...
app/controllers/sessions_controller.rb
View file @
158550cf
...
@@ -61,7 +61,7 @@ class SessionsController < Devise::SessionsController
...
@@ -61,7 +61,7 @@ class SessionsController < Devise::SessionsController
return
unless
user
&&
user
.
require_password?
return
unless
user
&&
user
.
require_password?
token
=
user
.
generate_reset_token
token
=
user
.
generate_reset_token
user
.
sav
e
Users
::
UpdateService
.
new
(
user
,
user
).
execut
e
redirect_to
edit_user_password_path
(
reset_password_token:
token
),
redirect_to
edit_user_password_path
(
reset_password_token:
token
),
notice:
"Please create a password for your new account."
notice:
"Please create a password for your new account."
...
...
app/services/users/update_service.rb
View file @
158550cf
module
Users
module
Users
# Service for
creating a new
user.
# Service for
updating a
user.
class
UpdateService
<
BaseService
class
UpdateService
<
BaseService
def
initialize
(
current_user
,
user
,
params
=
{})
def
initialize
(
current_user
,
user
,
params
=
{})
@current_user
=
current_user
@current_user
=
current_user
...
@@ -7,10 +7,10 @@ module Users
...
@@ -7,10 +7,10 @@ module Users
@params
=
params
.
dup
@params
=
params
.
dup
end
end
def
execute
(
skip_authorization:
false
,
&
block
)
def
execute
(
skip_authorization:
false
,
validate:
true
,
&
block
)
assign_attributes
(
skip_authorization
,
&
block
)
assign_attributes
(
skip_authorization
,
&
block
)
if
@user
.
save
||
!
@user
.
changed?
&&
@user
.
errors
.
empty?
if
@user
.
save
(
validate:
validate
)
||
!
@user
.
changed?
&&
@user
.
errors
.
empty?
success
success
else
else
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
))
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
))
...
...
lib/api/internal.rb
View file @
158550cf
...
@@ -133,7 +133,7 @@ module API
...
@@ -133,7 +133,7 @@ module API
end
end
codes
=
user
.
generate_otp_backup_codes!
codes
=
user
.
generate_otp_backup_codes!
user
.
sav
e!
::
Users
::
UpdateService
.
new
(
user
,
user
).
execut
e!
{
success:
true
,
recovery_codes:
codes
}
{
success:
true
,
recovery_codes:
codes
}
end
end
...
...
lib/api/users.rb
View file @
158550cf
...
@@ -278,7 +278,7 @@ module API
...
@@ -278,7 +278,7 @@ module API
email
.
destroy
email
.
destroy
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
::
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
user
.
update_secondary_emails!
user
.
update_secondary_emails!
end
end
end
end
...
@@ -511,7 +511,7 @@ module API
...
@@ -511,7 +511,7 @@ module API
not_found!
(
'Email'
)
unless
email
not_found!
(
'Email'
)
unless
email
email
.
destroy
email
.
destroy
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
::
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
user
.
update_secondary_emails!
user
.
update_secondary_emails!
end
end
end
end
...
...
lib/gitlab/ldap/access.rb
View file @
158550cf
...
@@ -17,7 +17,8 @@ module Gitlab
...
@@ -17,7 +17,8 @@ module Gitlab
self
.
open
(
user
)
do
|
access
|
self
.
open
(
user
)
do
|
access
|
if
access
.
allowed?
if
access
.
allowed?
user
.
last_credential_check_at
=
Time
.
now
user
.
last_credential_check_at
=
Time
.
now
user
.
save
Users
::
UpdateService
.
new
(
user
,
user
).
execute
true
true
else
else
false
false
...
...
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