Created
February 16, 2016 01:12
-
-
Save armandofox/41e6653f9250149532e6 to your computer and use it in GitHub Desktop.
sessions_controller.rb
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 | |
# 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