Module: Zendesk::RemoteAuthHelper
- Defined in:
- lib/zendesk_remote_auth.rb
Overview
Provides the method that generates the auth url. Mixin where required.
Instance Method Summary collapse
-
#zendesk_remote_auth_url(user_or_params) ⇒ Object
Takes a hash of parameters and generates the hashed auth url.
Instance Method Details
#zendesk_remote_auth_url(user_or_params) ⇒ Object
Takes a hash of parameters and generates the hashed auth url. The hash must include the :name and :email for the user. See: www.zendesk.com/api/remote_authentication for a list of all of the parameters.
If the :timestamp is not provided, Time.now will be used. If an :external_id is provided, then the :hash will be generated.
As a convenience, a user object can be passed instead, but must respond_to? at least :email and :name. The :id of the user object will be used as the :external_id, and if the user responds to :zendesk_organization, that will be used as the :organization.
44 45 46 47 48 49 50 51 |
# File 'lib/zendesk_remote_auth.rb', line 44 def zendesk_remote_auth_url(user_or_params) params = user_or_params.is_a?(Hash) ? user_or_params : user_to_params(user_or_params) validate_params(params) params[:timestamp] = Time.now.utc.to_i unless params[:timestamp] params[:hash] = generate_hash(Zendesk::RemoteAuth.token, params) "#{Zendesk::RemoteAuth.auth_url}?#{params.to_query}" end |