Class: OmniAuth::Strategies::Zendesk
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Zendesk
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/zendesk.rb
Instance Method Summary collapse
Instance Method Details
#callback_phase ⇒ Object
45 46 47 48 |
# File 'lib/omniauth/strategies/zendesk.rb', line 45 def callback_phase return fail!(:invalid_credentials) if not identity or identity.email == '[email protected]' super end |
#identity ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/omniauth/strategies/zendesk.rb', line 50 def identity return unless site && username && password client = ZendeskAPI::Client.new do |c| c.url = "#{site}/api/v2" c.username = username c.password = password end @identity ||= client.current_user end |
#request_phase ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/omniauth/strategies/zendesk.rb', line 28 def request_phase if site && username && password r = Rack::Response.new r.redirect(callback_path, 307) r.finish else OmniAuth::Form.build( title: ([:title] || "Zendesk Authentication"), url: callback_path ) do |f| f.text_field 'Username', .params.username f.password_field 'Password', .params.password f.text_field 'Zendesk Site', .params.site end.to_response end end |