class OmniAuth::Strategies::YourMembershipToken
Constants
- E_YM_SESSION_ID_BLANK
- RACK_SESSION_KEY
Public Instance Methods
callback_phase()
click to toggle source
See discussion in `request_phase` re: the use of `env`.
Calls superclass method
# File lib/omniauth/strategies/your_membership_token.rb, line 51 def callback_phase ym_session_id = env['rack.session'][RACK_SESSION_KEY] fail!(E_YM_SESSION_ID_BLANK) if ym_session_id.blank? ym_session = YourMembership::Session.new(ym_session_id, 100) begin fail! 'Failed To Log In' unless ym_session.authenticated? rescue YourMembership::Error => e fail! e.error_description end @user_id = ym_session.user_id @access_token = ym_session.to_s super end
request_phase()
click to toggle source
# File lib/omniauth/strategies/your_membership_token.rb, line 21 def request_phase # We're doing this because the callback_url is built from the # options.name attribute which is built by down-casing the name of the # class. This returns an un-capitalized url which Rails will not # recognize as the same path as the devise controller. This is a forced # way to do this and probably has a more elegant solution. options.name = 'yourMembershipToken' # Build an Access Token session = YourMembership::Session.create token_hash = session.createToken(:RetUrl => callback_url) # Store the YourMembership session id somewhere it can be retrieved # during the callback_phase. # # In OmniAuth 1, we were able to do: # # request.params['ym_session'] = session.to_s # # but this seems no longer possible in OmniAuth 2 (as described in # https://github.com/omniauth/omniauth/issues/975). So, the only thing I # can think of is to use `env['rack.session']`. If a better solution # is discovered, we can revisit this decision. env['rack.session'][RACK_SESSION_KEY] = session.to_s # Redirect to token url redirect token_hash['GoToUrl'] end