mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Add oauth links to default template.
This commit is contained in:
parent
0aa41d6388
commit
b87dc84079
6 changed files with 13 additions and 5 deletions
|
@ -17,3 +17,9 @@
|
||||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||||
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
<%- if devise_mapping.oauthable? %>
|
||||||
|
<%- resource_class.oauth_providers.each do |provider| %>
|
||||||
|
<%= link_to "Sign in with #{provider.to_s.titleize}", oauth_authorize_url(resource_name, provider) %><br />
|
||||||
|
<% end =%>
|
||||||
|
<% end -%>
|
|
@ -30,6 +30,8 @@ en:
|
||||||
unlocks:
|
unlocks:
|
||||||
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
||||||
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
||||||
|
oauth_callbacks:
|
||||||
|
default: 'Successfully authorized from %{kind} account.'
|
||||||
mailer:
|
mailer:
|
||||||
confirmation_instructions:
|
confirmation_instructions:
|
||||||
subject: 'Confirmation instructions'
|
subject: 'Confirmation instructions'
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Devise
|
||||||
end
|
end
|
||||||
|
|
||||||
def oauth_model_callback
|
def oauth_model_callback
|
||||||
"authentication_for_#{oauth_callback}_oauth"
|
"find_for_#{oauth_callback}_oauth"
|
||||||
end
|
end
|
||||||
|
|
||||||
def callback_action
|
def callback_action
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Devise
|
||||||
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
||||||
def #{mapping}_oauth_authorize_url(provider, options={})
|
def #{mapping}_oauth_authorize_url(provider, options={})
|
||||||
if config = Devise.oauth_configs[provider.to_sym]
|
if config = Devise.oauth_configs[provider.to_sym]
|
||||||
options[:redirect_uri] ||= #{mapping}_oauth_callback_url
|
options[:redirect_uri] ||= #{mapping}_oauth_callback_url(provider.to_s)
|
||||||
config.authorize_url(options)
|
config.authorize_url(options)
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Could not find oauth provider \#{provider.inspect}"
|
raise ArgumentError, "Could not find oauth provider \#{provider.inspect}"
|
||||||
|
@ -16,7 +16,7 @@ module Devise
|
||||||
|
|
||||||
def oauth_authorize_url(resource_or_scope, *args)
|
def oauth_authorize_url(resource_or_scope, *args)
|
||||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||||
send("#{scope}_oauth_authorize_url}", *args)
|
send("#{scope}_oauth_authorize_url", *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def oauth_callback_url(resource_or_scope, *args)
|
def oauth_callback_url(resource_or_scope, *args)
|
||||||
|
|
|
@ -222,7 +222,7 @@ module ActionDispatch::Routing
|
||||||
|
|
||||||
def devise_oauth_callback(mapping, controllers) #:nodoc:
|
def devise_oauth_callback(mapping, controllers) #:nodoc:
|
||||||
get "/oauth/:action/callback", :action => Regexp.union(mapping.to.oauth_providers.map(&:to_s)),
|
get "/oauth/:action/callback", :action => Regexp.union(mapping.to.oauth_providers.map(&:to_s)),
|
||||||
:to => controllers[:oauth_callbacks], :as => :outh_callback
|
:to => controllers[:oauth_callbacks], :as => :oauth_callback
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_devise_exclusive_scope(new_path, new_as) #:nodoc:
|
def with_devise_exclusive_scope(new_path, new_as) #:nodoc:
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Devise
|
||||||
def model_contents
|
def model_contents
|
||||||
<<-CONTENT
|
<<-CONTENT
|
||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
# :token_authenticatable, :confirmable, :lockable, :timeoutable and :oauthable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue