Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/two_factor/destroy_service.rb')
-rw-r--r--app/services/two_factor/destroy_service.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/services/two_factor/destroy_service.rb b/app/services/two_factor/destroy_service.rb
index 859012c2153..3db9aefbe70 100644
--- a/app/services/two_factor/destroy_service.rb
+++ b/app/services/two_factor/destroy_service.rb
@@ -3,7 +3,7 @@
module TwoFactor
class DestroyService < ::TwoFactor::BaseService
def execute
- return error(_('You are not authorized to perform this action')) unless can?(current_user, :disable_two_factor, user)
+ return error(_('You are not authorized to perform this action')) unless authorized?
return error(_('Two-factor authentication is not enabled for this user')) unless user.two_factor_enabled?
result = disable_two_factor
@@ -15,6 +15,10 @@ module TwoFactor
private
+ def authorized?
+ can?(current_user, :disable_two_factor, user)
+ end
+
def disable_two_factor
::Users::UpdateService.new(current_user, user: user).execute do |user|
user.disable_two_factor!