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
3a1ff1e3
Commit
3a1ff1e3
authored
Jul 03, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update services to include the current user
parent
a9743cb2
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
37 additions
and
36 deletions
+37
-36
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+3
-3
app/controllers/profiles/avatars_controller.rb
app/controllers/profiles/avatars_controller.rb
+1
-1
app/controllers/profiles/emails_controller.rb
app/controllers/profiles/emails_controller.rb
+2
-2
app/controllers/profiles/notifications_controller.rb
app/controllers/profiles/notifications_controller.rb
+1
-1
app/controllers/profiles/passwords_controller.rb
app/controllers/profiles/passwords_controller.rb
+3
-3
app/controllers/profiles/preferences_controller.rb
app/controllers/profiles/preferences_controller.rb
+1
-1
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+3
-3
app/controllers/profiles_controller.rb
app/controllers/profiles_controller.rb
+5
-5
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+5
-5
lib/api/internal.rb
lib/api/internal.rb
+1
-1
lib/api/notification_settings.rb
lib/api/notification_settings.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+5
-5
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+4
-3
lib/gitlab/o_auth/user.rb
lib/gitlab/o_auth/user.rb
+1
-1
No files found.
app/controllers/admin/users_controller.rb
View file @
3a1ff1e3
...
...
@@ -128,7 +128,7 @@ class Admin::UsersController < Admin::ApplicationController
end
respond_to
do
|
format
|
result
=
Users
::
UpdateService
.
new
(
user
,
user_params_with_pass
).
execute
do
|
user
|
result
=
Users
::
UpdateService
.
new
(
current_user
,
user
,
user_params_with_pass
).
execute
do
|
user
|
user
.
skip_reconfirmation!
end
...
...
@@ -155,7 +155,7 @@ class Admin::UsersController < Admin::ApplicationController
def
remove_email
email
=
user
.
emails
.
find
(
params
[
:email_id
])
success
=
Emails
::
DestroyService
.
new
(
user
,
email:
email
.
email
).
execute
success
=
Emails
::
DestroyService
.
new
(
current_user
,
user
,
email:
email
.
email
).
execute
respond_to
do
|
format
|
if
success
...
...
@@ -226,7 +226,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def
update_user
(
&
block
)
result
=
Users
::
UpdateService
.
new
(
user
).
execute
(
&
block
)
result
=
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
(
&
block
)
result
[
:status
]
==
:success
end
...
...
app/controllers/profiles/avatars_controller.rb
View file @
3a1ff1e3
...
...
@@ -2,7 +2,7 @@ class Profiles::AvatarsController < Profiles::ApplicationController
def
destroy
@user
=
current_user
Users
::
UpdateService
.
new
(
@user
).
execute
{
|
user
|
user
.
remove_avatar!
}
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute
{
|
user
|
user
.
remove_avatar!
}
redirect_to
profile_path
,
status:
302
end
...
...
app/controllers/profiles/emails_controller.rb
View file @
3a1ff1e3
...
...
@@ -5,7 +5,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
end
def
create
@email
=
Emails
::
CreateService
.
new
(
current_user
,
email_params
).
execute
@email
=
Emails
::
CreateService
.
new
(
current_user
,
current_user
,
email_params
).
execute
if
@email
.
errors
.
blank?
NotificationService
.
new
.
new_email
(
@email
)
...
...
@@ -19,7 +19,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
def
destroy
@email
=
current_user
.
emails
.
find
(
params
[
:id
])
Emails
::
DestroyService
.
new
(
current_user
,
email:
@email
.
email
).
execute
Emails
::
DestroyService
.
new
(
current_user
,
current_user
,
email:
@email
.
email
).
execute
respond_to
do
|
format
|
format
.
html
{
redirect_to
profile_emails_url
,
status:
302
}
...
...
app/controllers/profiles/notifications_controller.rb
View file @
3a1ff1e3
...
...
@@ -7,7 +7,7 @@ class Profiles::NotificationsController < Profiles::ApplicationController
end
def
update
result
=
Users
::
UpdateService
.
new
(
current_user
,
user_params
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
current_user
,
user_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Notification settings saved"
...
...
app/controllers/profiles/passwords_controller.rb
View file @
3a1ff1e3
...
...
@@ -21,10 +21,10 @@ class Profiles::PasswordsController < Profiles::ApplicationController
password_automatically_set:
false
}
result
=
Users
::
UpdateService
.
new
(
@user
,
password_attributes
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
password_attributes
).
execute
if
result
[
:status
]
==
:success
Users
::
UpdateService
.
new
(
@user
,
password_expires_at:
nil
).
execute
Users
::
UpdateService
.
new
(
current_user
,
@user
,
password_expires_at:
nil
).
execute
redirect_to
root_path
,
notice:
'Password successfully changed'
else
...
...
@@ -46,7 +46,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController
return
end
result
=
Users
::
UpdateService
.
new
(
@user
,
password_attributes
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
password_attributes
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Password was successfully updated. Please login with it"
...
...
app/controllers/profiles/preferences_controller.rb
View file @
3a1ff1e3
...
...
@@ -6,7 +6,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController
def
update
begin
result
=
Users
::
UpdateService
.
new
(
user
,
preferences_params
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
user
,
preferences_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
'Preferences saved.'
...
...
app/controllers/profiles/two_factor_auths_controller.rb
View file @
3a1ff1e3
...
...
@@ -10,7 +10,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
current_user
.
otp_grace_period_started_at
=
Time
.
current
end
Users
::
UpdateService
.
new
(
current_user
).
execute!
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute!
if
two_factor_authentication_required?
&&
!
current_user
.
two_factor_enabled?
two_factor_authentication_reason
(
...
...
@@ -41,7 +41,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
def
create
if
current_user
.
validate_and_consume_otp!
(
params
[
:pin_code
])
Users
::
UpdateService
.
new
(
current_user
,
otp_required_for_login:
true
).
execute!
do
|
user
|
Users
::
UpdateService
.
new
(
current_user
,
current_user
,
otp_required_for_login:
true
).
execute!
do
|
user
|
@codes
=
user
.
generate_otp_backup_codes!
end
...
...
@@ -70,7 +70,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
end
def
codes
Users
::
UpdateService
.
new
(
current_user
).
execute!
do
|
user
|
Users
::
UpdateService
.
new
(
current_user
,
current_user
).
execute!
do
|
user
|
@codes
=
user
.
generate_otp_backup_codes!
end
end
...
...
app/controllers/profiles_controller.rb
View file @
3a1ff1e3
...
...
@@ -10,7 +10,7 @@ class ProfilesController < Profiles::ApplicationController
def
update
respond_to
do
|
format
|
result
=
Users
::
UpdateService
.
new
(
@user
,
user_params
).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
user_params
).
execute
if
result
[
:status
]
==
:success
message
=
"Profile was successfully updated"
...
...
@@ -25,7 +25,7 @@ class ProfilesController < Profiles::ApplicationController
end
def
reset_private_token
Users
::
UpdateService
.
new
(
@user
).
execute!
do
|
user
|
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute!
do
|
user
|
user
.
reset_authentication_token!
end
...
...
@@ -35,7 +35,7 @@ class ProfilesController < Profiles::ApplicationController
end
def
reset_incoming_email_token
Users
::
UpdateService
.
new
(
@user
).
execute!
do
|
user
|
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute!
do
|
user
|
user
.
reset_incoming_email_token!
end
...
...
@@ -45,7 +45,7 @@ class ProfilesController < Profiles::ApplicationController
end
def
reset_rss_token
Users
::
UpdateService
.
new
(
@user
).
execute!
do
|
user
|
Users
::
UpdateService
.
new
(
current_user
,
@user
).
execute!
do
|
user
|
user
.
reset_rss_token!
end
...
...
@@ -61,7 +61,7 @@ class ProfilesController < Profiles::ApplicationController
end
def
update_username
result
=
Users
::
UpdateService
.
new
(
@user
,
username:
user_params
[
:username
]).
execute
result
=
Users
::
UpdateService
.
new
(
current_user
,
@user
,
username:
user_params
[
:username
]).
execute
options
=
if
result
[
:status
]
==
:success
{
notice:
"Username successfully changed"
}
...
...
app/controllers/sessions_controller.rb
View file @
3a1ff1e3
...
...
@@ -57,7 +57,7 @@ class SessionsController < Devise::SessionsController
return
unless
user
&&
user
.
require_password_creation?
Users
::
UpdateService
.
new
(
user
).
execute
do
|
user
|
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute
do
|
user
|
@token
=
user
.
generate_reset_token
end
...
...
app/models/user.rb
View file @
3a1ff1e3
...
...
@@ -63,7 +63,7 @@ class User < ActiveRecord::Base
lease
=
Gitlab
::
ExclusiveLease
.
new
(
"user_update_tracked_fields:
#{
id
}
"
,
timeout:
1
.
hour
.
to_i
)
return
unless
lease
.
try_obtain
Users
::
UpdateService
.
new
(
self
).
execute
(
validate:
false
)
Users
::
UpdateService
.
new
(
self
,
self
).
execute
(
validate:
false
)
end
attr_accessor
:force_random_password
...
...
@@ -545,8 +545,8 @@ class User < ActiveRecord::Base
def
update_emails_with_primary_email
primary_email_record
=
emails
.
find_by
(
email:
email
)
if
primary_email_record
Emails
::
DestroyService
.
new
(
self
,
email:
email
).
execute
Emails
::
CreateService
.
new
(
self
,
email:
email_was
).
execute
Emails
::
DestroyService
.
new
(
self
,
self
,
email:
email
).
execute
Emails
::
CreateService
.
new
(
self
,
self
,
email:
email_was
).
execute
end
end
...
...
@@ -1023,7 +1023,7 @@ class User < ActiveRecord::Base
if
attempts_exceeded?
lock_access!
unless
access_locked?
else
Users
::
UpdateService
.
new
(
self
).
execute
(
validate:
false
)
Users
::
UpdateService
.
new
(
self
,
self
).
execute
(
validate:
false
)
end
end
...
...
@@ -1209,7 +1209,7 @@ class User < ActiveRecord::Base
&
creation_block
)
Users
::
UpdateService
.
new
(
user
).
execute
(
validate:
false
)
Users
::
UpdateService
.
new
(
user
,
user
).
execute
(
validate:
false
)
user
ensure
Gitlab
::
ExclusiveLease
.
cancel
(
lease_key
,
uuid
)
...
...
lib/api/internal.rb
View file @
3a1ff1e3
...
...
@@ -149,7 +149,7 @@ module API
codes
=
nil
::
Users
::
UpdateService
.
new
(
user
).
execute!
do
|
user
|
::
Users
::
UpdateService
.
new
(
current_user
,
user
).
execute!
do
|
user
|
codes
=
user
.
generate_otp_backup_codes!
end
...
...
lib/api/notification_settings.rb
View file @
3a1ff1e3
...
...
@@ -35,7 +35,7 @@ module API
new_notification_email
=
params
.
delete
(
:notification_email
)
if
new_notification_email
::
Users
::
UpdateService
.
new
(
current_user
,
notification_email:
new_notification_email
).
execute
::
Users
::
UpdateService
.
new
(
current_user
,
current_user
,
notification_email:
new_notification_email
).
execute
end
notification_setting
.
update
(
declared_params
(
include_missing:
false
))
...
...
lib/api/users.rb
View file @
3a1ff1e3
...
...
@@ -172,7 +172,7 @@ module API
user_params
[
:password_expires_at
]
=
Time
.
now
if
user_params
[
:password
].
present?
result
=
::
Users
::
UpdateService
.
new
(
user
,
user_params
.
except
(
:extern_uid
,
:provider
)).
execute
result
=
::
Users
::
UpdateService
.
new
(
current_user
,
user
,
user_params
.
except
(
:extern_uid
,
:provider
)).
execute
if
result
[
:status
]
==
:success
present
user
,
with:
Entities
::
UserPublic
...
...
@@ -332,7 +332,7 @@ module API
user
=
User
.
find_by
(
id:
params
.
delete
(
:id
))
not_found!
(
'User'
)
unless
user
email
=
Emails
::
CreateService
.
new
(
user
,
declared_params
(
include_missing:
false
)).
execute
email
=
Emails
::
CreateService
.
new
(
current_user
,
user
,
declared_params
(
include_missing:
false
)).
execute
if
email
.
errors
.
blank?
NotificationService
.
new
.
new_email
(
email
)
...
...
@@ -373,7 +373,7 @@ module API
not_found!
(
'Email'
)
unless
email
destroy_conditionally!
(
email
)
do
|
email
|
Emails
::
DestroyService
.
new
(
current_user
,
email:
email
.
email
).
execute
Emails
::
DestroyService
.
new
(
current_user
,
user
,
email:
email
.
email
).
execute
end
user
.
update_secondary_emails!
...
...
@@ -678,7 +678,7 @@ module API
requires
:email
,
type:
String
,
desc:
'The new email'
end
post
"emails"
do
email
=
Emails
::
CreateService
.
new
(
current_user
,
declared_params
).
execute
email
=
Emails
::
CreateService
.
new
(
current_user
,
current_user
,
declared_params
).
execute
if
email
.
errors
.
blank?
NotificationService
.
new
.
new_email
(
email
)
...
...
@@ -697,7 +697,7 @@ module API
not_found!
(
'Email'
)
unless
email
destroy_conditionally!
(
email
)
do
|
email
|
Emails
::
DestroyService
.
new
(
current_user
,
email:
email
.
email
).
execute
Emails
::
DestroyService
.
new
(
current_user
,
current_user
,
email:
email
.
email
).
execute
end
current_user
.
update_secondary_emails!
...
...
lib/gitlab/ldap/access.rb
View file @
3a1ff1e3
...
...
@@ -20,7 +20,7 @@ module Gitlab
# permissions to keep things clean
if
access
.
allowed?
access
.
update_user
Users
::
UpdateService
.
new
(
user
,
last_credential_check_at:
Time
.
now
).
execute
Users
::
UpdateService
.
new
(
user
,
user
,
last_credential_check_at:
Time
.
now
).
execute
true
else
...
...
@@ -172,8 +172,9 @@ module Gitlab
return
false
if
user
.
email
==
ldap_email
user
.
skip_reconfirmation!
user
.
update
(
email:
ldap_email
)
Users
::
UpdateService
.
new
(
user
,
user
,
email:
ldap_email
).
execute
do
|
user
|
user
.
skip_reconfirmation!
end
end
def
update_identity
...
...
lib/gitlab/o_auth/user.rb
View file @
3a1ff1e3
...
...
@@ -34,7 +34,7 @@ module Gitlab
block_after_save
=
needs_blocking?
Users
::
UpdateService
.
new
(
gl_user
).
execute!
Users
::
UpdateService
.
new
(
gl_user
,
gl_user
).
execute!
gl_user
.
block
if
block_after_save
...
...
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