Skip to content

Instantly share code, notes, and snippets.

@tibastral
Created May 8, 2011 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tibastral/961744 to your computer and use it in GitHub Desktop.
Save tibastral/961744 to your computer and use it in GitHub Desktop.
omniauth session controller
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