Class: OmniAuth::Strategies::BrowserID
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::BrowserID
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/browser_id.rb
Instance Method Summary collapse
- #connection ⇒ Object
- #failure_path ⇒ Object
- #other_phase ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
Instance Method Details
#connection ⇒ Object
78 79 80 |
# File 'lib/omniauth/strategies/browser_id.rb', line 78 def connection resp = Faraday.new(:url => [:verify_url]) end |
#failure_path ⇒ Object
23 24 25 |
# File 'lib/omniauth/strategies/browser_id.rb', line 23 def failure_path [:failure_path] || "#{path_prefix}/failure" end |
#other_phase ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/omniauth/strategies/browser_id.rb', line 15 def other_phase if on_path?(failure_path) fail!('invalid_credentials') else call_app! end end |
#raw_info ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/omniauth/strategies/browser_id.rb', line 69 def raw_info response = connection.post('', :assertion => request.params['assertion'], :audience => full_host ) MultiJson.decode(response.body) end |
#request_phase ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/browser_id.rb', line 27 def request_phase OmniAuth::Form.build( :title => "BrowserID Login", :url => callback_path, :header_info => <<-HTML <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script src="https://browserid.org/include.js" type="text/javascript"></script> <script type='text/javascript'> function loginViaEmail() { navigator.id.getVerifiedEmail(function(assertion) { if (assertion) { $('input[name=assertion]').val(assertion); $('form').submit(); } else { window.location = "#{failure_path}" } }); } $(function() { $('button').click(function() { loginViaEmail(); return false; }); }); </script> HTML ) do |f| f.html "<input type='hidden' name='assertion'/><p>Click 'Connect' to sign in with BrowserID.</p>" end.to_response end |