blob: 81a70a771cfdcb2dc2b5f03bebb98d8d73ab3870 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# frozen_string_literal: true
module Ci
module Runners
class ResetRegistrationTokenService
# @param [ApplicationSetting, Project, Group] scope: the scope of the reset operation
# @param [User] user: the user performing the operation
def initialize(scope, user)
@scope = scope
@user = user
end
def execute
return unless @user.present? && @user.can?(:update_runners_registration_token, scope)
if scope.respond_to?(:runners_registration_token)
scope.reset_runners_registration_token!
scope.runners_registration_token
else
scope.reset_runners_token!
scope.runners_token
end
end
private
attr_reader :scope, :user
end
end
end
Ci::Runners::ResetRegistrationTokenService.prepend_mod
|