Class: LedSign::Session
- Inherits:
-
Object
- Object
- LedSign::Session
- Defined in:
- lib/ledsign-api.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(token = nil, params = nil) ⇒ Session
constructor
A new instance of Session.
- #login_url ⇒ Object
-
#site ⇒ Object
Used by ActiveResource::Base to make all non-authentication API calls (ShopifyAPI::Base.site set in ShopifyLoginProtection#shopify_session).
- #valid? ⇒ Boolean
Constructor Details
#initialize(token = nil, params = nil) ⇒ Session
Returns a new instance of Session.
33 34 35 36 37 38 39 40 41 |
# File 'lib/ledsign-api.rb', line 33 def initialize(token = nil, params = nil) self.token = token if params && params[:signature] unless self.class.validate_signature(params) && params[:timestamp].to_i > 24.hours.ago.utc.to_i raise "Invalid Signature: Possible malicious login" end end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
27 28 29 |
# File 'lib/ledsign-api.rb', line 27 def name @name end |
#token ⇒ Object
Returns the value of attribute token.
27 28 29 |
# File 'lib/ledsign-api.rb', line 27 def token @token end |
Class Method Details
.setup(params) ⇒ Object
29 30 31 |
# File 'lib/ledsign-api.rb', line 29 def self.setup(params) params.each { |k,value| send("#{k}=", value) } end |
Instance Method Details
#login_url ⇒ Object
43 44 45 |
# File 'lib/ledsign-api.rb', line 43 def login_url "http://#{self.class.url}/login/?api_key=#{api_key}" end |
#site ⇒ Object
Used by ActiveResource::Base to make all non-authentication API calls (ShopifyAPI::Base.site set in ShopifyLoginProtection#shopify_session)
49 50 51 |
# File 'lib/ledsign-api.rb', line 49 def site "#{protocol}://#{api_key}:#{computed_password}@#{self.class.url}" end |
#valid? ⇒ Boolean
53 54 55 |
# File 'lib/ledsign-api.rb', line 53 def valid? token.present? end |