Skip to content

Instantly share code, notes, and snippets.

@armandofox
Created February 16, 2016 01:12
Show Gist options
  • Save armandofox/41e6653f9250149532e6 to your computer and use it in GitHub Desktop.
Save armandofox/41e6653f9250149532e6 to your computer and use it in GitHub Desktop.
sessions_controller.rb
class SessionsController < ApplicationController
# user shouldn't have to be logged in before logging in!
skip_before_filter :set_current_user
def create
auth=request.env["omniauth.auth"]
user=Moviegoer.find_by_provider_and_uid(auth["provider"],auth["uid"]) ||
Moviegoer.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_to movies_path
end
def destroy
session.delete(:user_id)
flash[:notice] = 'Logged out successfully.'
redirect_to movies_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment