Omniauth routes
This commit is contained in:
parent
331c95893c
commit
049e9b7066
3
Gemfile
3
Gemfile
|
|
@ -25,6 +25,9 @@ gem 'eventmachine'
|
|||
gem 'amqp'
|
||||
gem 'logging-rails', :require => 'logging/rails'
|
||||
gem 'tire'
|
||||
gem 'rb-readline'
|
||||
gem 'omniauth'
|
||||
gem 'omniauth-facebook'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rspec-rails', '2.11.0'
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ class SessionsController < ApplicationController
|
|||
def new
|
||||
end
|
||||
|
||||
# oauth information:
|
||||
# http://net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/
|
||||
|
||||
def create
|
||||
user = User.find_by_email(params[:session][:email])
|
||||
if user && user.authenticate(params[:session][:password])
|
||||
|
|
@ -15,8 +18,17 @@ class SessionsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def create_oauth
|
||||
auth_hash = request.env['omniauth.auth']
|
||||
render :text => auth_hash.inspect
|
||||
end
|
||||
|
||||
def destroy
|
||||
sign_out
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
|
||||
def failure
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :facebook, '468555793186398', '546a5b253972f3e2e8b36d9a3dd5a06e'
|
||||
end
|
||||
|
|
@ -16,6 +16,9 @@ SampleApp::Application.routes.draw do
|
|||
match '/signup', to: 'users#new'
|
||||
match '/signin', to: 'sessions#new'
|
||||
match '/signout', to: 'sessions#destroy', via: :delete
|
||||
# oauth
|
||||
match '/auth/:provider/callback', :to => 'sessions#create_oauth'
|
||||
match '/auth/failure', :to => 'sessions#failure'
|
||||
|
||||
match '/help', to: 'static_pages#help'
|
||||
match '/about', to: 'static_pages#about'
|
||||
|
|
|
|||
Loading…
Reference in New Issue