Class: PersonalAccessTokens::RevokeService
- Inherits:
-
BaseService
- Object
- BaseService
- PersonalAccessTokens::RevokeService
- Defined in:
- app/services/personal_access_tokens/revoke_service.rb
Constant Summary collapse
- VALID_SOURCES =
%i[self secret_detection].freeze
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes inherited from BaseService
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user = nil, token: nil, group: nil, source: nil) ⇒ RevokeService
constructor
A new instance of RevokeService.
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(current_user = nil, token: nil, group: nil, source: nil) ⇒ RevokeService
Returns a new instance of RevokeService.
9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/personal_access_tokens/revoke_service.rb', line 9 def initialize(current_user = nil, token: nil, group: nil, source: nil) @current_user = current_user @token = token @group = group @source = source @source = :self if @current_user && !@source raise ArgumentError unless VALID_SOURCES.include?(@source) end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
5 6 7 |
# File 'app/services/personal_access_tokens/revoke_service.rb', line 5 def current_user @current_user end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'app/services/personal_access_tokens/revoke_service.rb', line 5 def group @group end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
5 6 7 |
# File 'app/services/personal_access_tokens/revoke_service.rb', line 5 def token @token end |
Instance Method Details
#execute ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/personal_access_tokens/revoke_service.rb', line 20 def execute return ServiceResponse.error(message: 'Not permitted to revoke') unless revocation_permitted? if token.revoke! log_event notification_service.access_token_revoked(token.user, token.name, @source) ServiceResponse.success(message: ) else ServiceResponse.error(message: ) end end |