Last active
August 23, 2016 15:10
-
-
Save kaileeagray/b12fb7c63a206bfc34a6d1ae299feeba to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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