1
0
Fork 0
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:
José Valim 2010-07-13 21:10:33 +02:00
parent 0aa41d6388
commit b87dc84079
6 changed files with 13 additions and 5 deletions

View file

@ -17,3 +17,9 @@
<%- 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 />
<% 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 -%>

View file

@ -30,6 +30,8 @@ en:
unlocks:
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.'
oauth_callbacks:
default: 'Successfully authorized from %{kind} account.'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'

View file

@ -42,7 +42,7 @@ module Devise
end
def oauth_model_callback
"authentication_for_#{oauth_callback}_oauth"
"find_for_#{oauth_callback}_oauth"
end
def callback_action

View file

@ -5,7 +5,7 @@ module Devise
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def #{mapping}_oauth_authorize_url(provider, options={})
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)
else
raise ArgumentError, "Could not find oauth provider \#{provider.inspect}"
@ -16,7 +16,7 @@ module Devise
def oauth_authorize_url(resource_or_scope, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
send("#{scope}_oauth_authorize_url}", *args)
send("#{scope}_oauth_authorize_url", *args)
end
def oauth_callback_url(resource_or_scope, *args)

View file

@ -222,7 +222,7 @@ module ActionDispatch::Routing
def devise_oauth_callback(mapping, controllers) #:nodoc:
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
def with_devise_exclusive_scope(new_path, new_as) #:nodoc:

View file

@ -4,7 +4,7 @@ module Devise
def model_contents
<<-CONTENT
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
# :token_authenticatable, :confirmable, :lockable, :timeoutable and :oauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable