2022-05-07 20:08:51 +05:30
|
|
|
# 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)
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
if scope.respond_to?(:runners_registration_token)
|
2022-05-07 20:08:51 +05:30
|
|
|
scope.reset_runners_registration_token!
|
2022-07-23 23:45:48 +05:30
|
|
|
scope.runners_registration_token
|
|
|
|
else
|
2022-05-07 20:08:51 +05:30
|
|
|
scope.reset_runners_token!
|
|
|
|
scope.runners_token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :scope, :user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
Ci::Runners::ResetRegistrationTokenService.prepend_mod
|