Created
May 8, 2011 22:25
-
-
Save tibastral/961744 to your computer and use it in GitHub Desktop.
omniauth session controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < ApplicationController | |
def create | |
auth = request.env["omniauth.auth"] | |
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) | |
user ||= User.create_with_omniauth(auth) | |
session[:user_id] = user.id | |
redirect_to [:dashboard, user] | |
end | |
def destroy | |
session[:user_id] = nil | |
redirect_to root_path, :notice => "Signed out!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment