Sha256: ac7bf462baf4b273654c83fc4632102374264ed138df809a5fc6dd1ec63d1beb
Contents?: true
Size: 885 Bytes
Versions: 2
Compression:
Stored size: 885 Bytes
Contents
#can be included in for example a Rails controller to enable easily #authenticating requests module Shutl module Auth module Session def session @session ||= {} end end module AuthenticatedRequest def self.included base unless base.instance_methods.include? :session base.class_eval do include Shutl::Auth::Session end end end def request_access_token return session[:access_token] if session[:access_token] Shutl::Auth.access_token! end def access_token session[:access_token] ||= request_access_token end def authenticated_request &blk begin yield rescue Shutl::UnauthorizedAccess => e session[:access_token] = nil access_token yield end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shutl_auth-0.8.1 | lib/shutl/auth/authenticated_request.rb |
shutl_auth-0.8.0 | lib/shutl/auth/authenticated_request.rb |