Class: Ci::Trigger
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationRecord
- Ci::Trigger
- Defined in:
- app/models/ci/trigger.rb
Constant Summary collapse
- TRIGGER_TOKEN_PREFIX =
'glptt-'- EXPIRED_TOKEN_RETENTION =
30.days
Constants included from Expirable
Constants included from Limitable
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary collapse
Instance Method Summary collapse
- #can_access_project? ⇒ Boolean
- #last_used ⇒ Object
- #short_token ⇒ Object (also: #trigger_short_token)
- #token=(token_value) ⇒ Object
Methods included from Expirable
#expired?, #expires?, #expires_soon?
Methods included from Limitable
Methods included from Presentable
Methods inherited from ApplicationRecord
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.prefix_for_trigger_token ⇒ Object
56 57 58 |
# File 'app/models/ci/trigger.rb', line 56 def self.prefix_for_trigger_token ::Authn::TokenField::PrefixHelper.prepend_instance_prefix(TRIGGER_TOKEN_PREFIX) end |
Instance Method Details
#can_access_project? ⇒ Boolean
79 80 81 |
# File 'app/models/ci/trigger.rb', line 79 def can_access_project? Ability.allowed?(self.owner, :create_build, project) end |
#last_used ⇒ Object
64 65 66 67 68 69 |
# File 'app/models/ci/trigger.rb', line 64 def last_used # The instance should be preloaded by `.with_last_used` for performance reason return attributes['last_used'] if attributes.has_key?('last_used') pipelines.order(id: :desc).pick(:created_at) end |
#short_token ⇒ Object Also known as: trigger_short_token
71 72 73 74 75 76 |
# File 'app/models/ci/trigger.rb', line 71 def short_token return unless token.present? token.delete_prefix(Authn::TokenField::PrefixHelper.instance_prefix) .delete_prefix(TRIGGER_TOKEN_PREFIX)[0...4] end |
#token=(token_value) ⇒ Object
60 61 62 |
# File 'app/models/ci/trigger.rb', line 60 def token=(token_value) self.set_token(token_value) end |