Module: Sinatra::Shopify::Methods
- Defined in:
- lib/sinatra/shopify-sinatra-app.rb
Instance Method Summary collapse
-
#after_shopify_auth ⇒ Object
designed to be overridden.
-
#shop_origin ⇒ Object
for the app bridge initializer.
- #shopify_session(&blk) ⇒ Object
Instance Method Details
#after_shopify_auth ⇒ Object
designed to be overridden
15 16 |
# File 'lib/sinatra/shopify-sinatra-app.rb', line 15 def after_shopify_auth end |
#shop_origin ⇒ Object
for the app bridge initializer
19 20 21 |
# File 'lib/sinatra/shopify-sinatra-app.rb', line 19 def shop_origin "#{session[:shopify][:shop]}" end |
#shopify_session(&blk) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sinatra/shopify-sinatra-app.rb', line 23 def shopify_session(&blk) return_to = request.path return_params = request.params if no_session? authenticate(return_to, return_params) elsif different_shop? clear_session authenticate(return_to, return_params) else shop_name = session[:shopify][:shop] token = session[:shopify][:token] activate_shopify_api(shop_name, token) yield shop_name end rescue ActiveResource::UnauthorizedAccess clear_session shop = Shop.find_by(name: shop_name) shop.token = nil shop.save redirect request.path end |