Class: OmniAuth::Strategies::Nationbuilder
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Nationbuilder
- Defined in:
- lib/omniauth/strategies/nationbuilder.rb
Instance Method Summary collapse
- #callback_phase ⇒ Object
-
#callback_url ⇒ Object
Nationbuilder fails with an invalid callback if the query string is passed along.
-
#client ⇒ Object
Configure site before super initialises the OAuth2 Client.
-
#get_slug ⇒ Object
Build a form to get the nations slug if one has not been supplied.
-
#request_phase ⇒ Object
Override the normal OAuth request_phase to get a slug from the user if one hasn’t been supplied, and insert the slug into the site url.
-
#slug ⇒ Object
Returns the slug, nil if one has not been specified anywhere.
Instance Method Details
#callback_phase ⇒ Object
49 50 51 52 |
# File 'lib/omniauth/strategies/nationbuilder.rb', line 49 def callback_phase .[:slug] = session.delete("omniauth.nationbuilder.slug") super end |
#callback_url ⇒ Object
Nationbuilder fails with an invalid callback if the query string is passed along
56 57 58 |
# File 'lib/omniauth/strategies/nationbuilder.rb', line 56 def callback_url full_host + script_name + callback_path end |
#client ⇒ Object
Configure site before super initialises the OAuth2 Client
24 25 26 27 28 |
# File 'lib/omniauth/strategies/nationbuilder.rb', line 24 def client .[:site] = 'https://' + .[:slug] + '.nationbuilder.com' log :debug, "Nation to authorise " + deep_symbolize(.).inspect super end |
#get_slug ⇒ Object
Build a form to get the nations slug if one has not been supplied
15 16 17 18 19 20 21 |
# File 'lib/omniauth/strategies/nationbuilder.rb', line 15 def get_slug f = OmniAuth::Form.new(:title => 'NationBuilder Authentication') f.label_field("Your Nation's Slug", .slug_param) f.input_field('url', .slug_param) f. "Connect to your Nation" f.to_response end |
#request_phase ⇒ Object
Override the normal OAuth request_phase to get a slug from the user if one hasn’t been supplied, and insert the slug into the site url
39 40 41 42 43 44 45 46 47 |
# File 'lib/omniauth/strategies/nationbuilder.rb', line 39 def request_phase if slug # Store slug on the session session["omniauth.nationbuilder.slug"] = .[:slug] = slug super else get_slug end end |
#slug ⇒ Object
Returns the slug, nil if one has not been specified anywhere
31 32 33 34 35 |
# File 'lib/omniauth/strategies/nationbuilder.rb', line 31 def slug s = .nation_slug || request.params[.slug_param.to_s] s = nil if s == '' s end |