Sha256: 2685c0ffc0bc7495346fad8b37d6d3af2f43a25ca2c321c283253b4ca2a41905

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

module AuthlogicRpx
	module Helper

		# helper to insert an embedded iframe RPX login
		# takes options hash:
		#   * <tt>app_name:</tt> name of the application (will be prepended to RPX domain and used in RPX dialogues)
		#   * <tt>return_url:</tt> url for the RPX callback (e.g. user_sessions_url)
		#   * <tt>add_rpx:</tt> if true, requests RPX callback to add to current session. Else runs normal authentication process (default)
		#
		def rpx_embed(options = {})
			params = (
				{ :authenticity_token => form_authenticity_token, :add_rpx => options[:add_rpx] }.collect { |n| "#{n[0]}=#{ u(n[1]) }" if n[1] }
			).compact.join('&')
			RPXNow.embed_code(options[:app_name], u( options[:return_url] + '?' + params ) )
		end

		# helper to insert a link to pop-up RPX login
		# takes options hash:
		#   * <tt>link_text:</tt> text to use in the link
		#   * <tt>app_name:</tt> name of the application (will be prepended to RPX domain and used in RPX dialogues)
		#   * <tt>return_url:</tt> url for the RPX callback (e.g. user_sessions_url)
		#   * <tt>add_rpx:</tt> if true, requests RPX callback to add to current session. Else runs normal authentication process (default)
		#   * <tt>unobtrusive:</tt> true/false; sets javascript style for link. Default: true
		#
		# NB: i18n considerations? supports a :language parameter (not tested)
		def rpx_popup(options = {})
			params = (
				{ :authenticity_token => form_authenticity_token, :add_rpx => options[:add_rpx] }.collect { |n| "#{n[0]}=#{ u(n[1]) }" if n[1] }
			).compact.join('&')
			unobtrusive = options[:unobtrusive].nil? ? true : options[:unobtrusive]
			return_url = options[:return_url] + '?' + params 
			return_url = u( return_url ) if unobtrusive # double-encoding required only if unobtrusive mode used
			RPXNow.popup_code(
  				options[:link_text], 
  				options[:app_name],
  				return_url,
  				:unobtrusive=>unobtrusive
  			) 
		end

	end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
sidonath-authlogic_rpx-1.0.4em lib/authlogic_rpx/helper.rb
sidonath-authlogic_rpx-1.0.4b lib/authlogic_rpx/helper.rb
kent-authlogic_rpx-0.1.0 lib/authlogic_rpx/helper.rb