class Wor::Authentication::DecodedToken
Attributes
payload[R]
Public Class Methods
new(payload)
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 6 def initialize(payload) @payload = payload end
Public Instance Methods
able_to_renew?()
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 27 def able_to_renew? # TODO: Use a ruby standard library for time fetch(:maximum_useful_date).present? && Time.zone.now.to_i < fetch(:maximum_useful_date) end
expired?()
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 22 def expired? # TODO: Use a ruby standard library for time fetch(:expiration_date).present? && Time.zone.now.to_i > fetch(:expiration_date) end
fetch(key)
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 18 def fetch(key) payload[key.to_sym] || payload[key.to_s] end
valid_renew_id?(renew_id)
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 32 def valid_renew_id?(renew_id) (fetch(:renew_id).blank? || renew_id.blank?) || renew_id == fetch(:renew_id) end
validate!(entity_custom_validation = nil)
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 10 def validate!(entity_custom_validation = nil) unless valid_entity_custom_validation?(entity_custom_validation) raise Wor::Authentication::Exceptions::EntityCustomValidationError end raise Wor::Authentication::Exceptions::NotRenewableTokenError unless able_to_renew? raise Wor::Authentication::Exceptions::ExpiredTokenError if expired? end
Private Instance Methods
valid_entity_custom_validation?(entity_custom_validation)
click to toggle source
# File lib/wor/authentication/decoded_token.rb, line 38 def valid_entity_custom_validation?(entity_custom_validation) fetch(:entity_custom_validation).blank? || entity_custom_validation == fetch(:entity_custom_validation) end