Skip to content

Instantly share code, notes, and snippets.

@kaileeagray
Last active August 23, 2016 15:10
Show Gist options
  • Select an option

  • Save kaileeagray/b12fb7c63a206bfc34a6d1ae299feeba to your computer and use it in GitHub Desktop.

Select an option

Save kaileeagray/b12fb7c63a206bfc34a6d1ae299feeba to your computer and use it in GitHub Desktop.
class SessionsController < ApplicationController
def new
end
def create
@list = List.new
@lists = List.all
if auth = request.env["omniauth.auth"]
@user = User.find_or_create_by_omniauth(auth)
session[:user_id] = @user.id
redirect_to root_path
else
user = User.find_or_create_by(:email => params[:email])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to root_path
else
render 'sessions/new'
end
end
end
def destroy
reset_session
redirect_to login_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment