Module: Devise::OmniAuth::UrlHelpers

Defined in:
lib/devise/omniauth/url_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_helpers(mapping) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
# File 'lib/devise/omniauth/url_helpers.rb', line 4

def self.define_helpers(mapping)
  return unless mapping.omniauthable?

  mapping = mapping.name

  class_eval do
    define_method("#{mapping}_omniauth_authorize_path") do |provider, *args|
      ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
      [Devise] #{mapping}_omniauth_authorize_path(#{provider.inspect}) is deprecated and it will be removed from Devise 4.1.

      Please use #{mapping}_#{provider}_omniauth_authorize_path instead.
      DEPRECATION
      send("#{mapping}_#{provider}_omniauth_authorize_path", *args)
    end

    define_method("#{mapping}_omniauth_authorize_url") do |provider, *args|
      ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
      [Devise] #{mapping}_omniauth_authorize_url(#{provider.inspect}) is deprecated and it will be removed from Devise 4.1.

      Please use #{mapping}_#{provider}_omniauth_authorize_url instead.
      DEPRECATION
      send("#{mapping}_#{provider}_omniauth_authorize_url", *args)
    end

    define_method("#{mapping}_omniauth_callback_path") do |provider, *args|
      ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
      [Devise] #{mapping}_omniauth_callback_path(#{provider.inspect}) is deprecated and it will be removed from Devise 4.1.

      Please use #{mapping}_#{provider}_omniauth_callback_path instead.
      DEPRECATION
      send("#{mapping}_#{provider}_omniauth_callback_path", *args)
    end

    define_method("#{mapping}_omniauth_callback_url") do |provider, *args|
      ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
      [Devise] #{mapping}_omniauth_callback_url(#{provider.inspect}) is deprecated and it will be removed from Devise 4.1.

      Please use #{mapping}_#{provider}_omniauth_callback_url instead.
      DEPRECATION
      send("#{mapping}_#{provider}_omniauth_callback_url", *args)
    end
  end

  ActiveSupport.on_load(:action_controller) do
    if respond_to?(:helper_method)
      helper_method "#{mapping}_omniauth_authorize_path", "#{mapping}_omniauth_authorize_url"
      helper_method "#{mapping}_omniauth_callback_path", "#{mapping}_omniauth_callback_url"
    end
  end
end

Instance Method Details

#omniauth_authorize_path(resource_or_scope, provider, *args) ⇒ Object



55
56
57
58
# File 'lib/devise/omniauth/url_helpers.rb', line 55

def omniauth_authorize_path(resource_or_scope, provider, *args)
  scope = Devise::Mapping.find_scope!(resource_or_scope)
  _devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_path", *args)
end

#omniauth_authorize_url(resource_or_scope, provider, *args) ⇒ Object



60
61
62
63
# File 'lib/devise/omniauth/url_helpers.rb', line 60

def omniauth_authorize_url(resource_or_scope, provider, *args)
  scope = Devise::Mapping.find_scope!(resource_or_scope)
  _devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_url", *args)
end

#omniauth_callback_path(resource_or_scope, provider, *args) ⇒ Object



65
66
67
68
# File 'lib/devise/omniauth/url_helpers.rb', line 65

def omniauth_callback_path(resource_or_scope, provider, *args)
  scope = Devise::Mapping.find_scope!(resource_or_scope)
  _devise_route_context.send("#{scope}_#{provider}_omniauth_callback_path", *args)
end

#omniauth_callback_url(resource_or_scope, provider, *args) ⇒ Object



70
71
72
73
# File 'lib/devise/omniauth/url_helpers.rb', line 70

def omniauth_callback_url(resource_or_scope, provider, *args)
  scope = Devise::Mapping.find_scope!(resource_or_scope)
  _devise_route_context.send("#{scope}_#{provider}_omniauth_callback_url", *args)
end