2012-02-25 22:43:17 +00:00
|
|
|
class SessionsController < ApplicationController
|
|
|
|
before_filter :load_omniauth_auth, :only => :create
|
|
|
|
|
|
|
|
def create
|
2012-02-26 17:13:46 +00:00
|
|
|
user = User.find_by_provider_and_uid(@auth["provider"], @auth["uid"]) ||
|
|
|
|
User.create_with_omniauth(@auth)
|
2012-02-25 22:43:17 +00:00
|
|
|
|
|
|
|
self.current_user = user
|
|
|
|
redirect_to root_url, :notice => "Signed in!"
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
self.current_user = nil
|
|
|
|
redirect_to root_url, :notice => "Signed out!"
|
|
|
|
end
|
|
|
|
|
|
|
|
def failure
|
2012-02-26 17:13:46 +00:00
|
|
|
flash[:error] = params[:message]
|
2012-02-25 22:43:17 +00:00
|
|
|
redirect_to root_url
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def load_omniauth_auth
|
|
|
|
@auth = request.env["omniauth.auth"]
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|