Class: OctopusAuth::Issue
- Inherits:
-
Object
- Object
- OctopusAuth::Issue
- Defined in:
- lib/octopus_auth/issue.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(scope, owner_type, owner_id, creator_id, expires_at: nil) ⇒ Issue
constructor
A new instance of Issue.
Constructor Details
#initialize(scope, owner_type, owner_id, creator_id, expires_at: nil) ⇒ Issue
Returns a new instance of Issue.
5 6 7 8 9 10 11 12 |
# File 'lib/octopus_auth/issue.rb', line 5 def initialize(scope, owner_type, owner_id, creator_id, expires_at: nil) @owner_type = owner_type @owner_id = owner_id @creator_id = creator_id @scope = scope.to_sym @expires_at = expires_at end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/octopus_auth/issue.rb', line 14 def execute access_token = OctopusAuth.configuration.model_class.new # Set attributes access_token.issued_at = Time.now.utc if @expires_at access_token.expires_at = @expires_at else access_token.expires_at = access_token.issued_at + OctopusAuth.configuration.token_life_time end access_token.active = true access_token.owner_type = @owner_type access_token.owner_id = @owner_id access_token.creator_id = @creator_id access_token.scope = filtered_scope access_token.token = generate_token access_token.save! OctopusAuth::Decorators::Default.new(access_token) end |