asciinema.org/app/controllers/sessions_controller.rb

37 lines
641 B
Ruby
Raw Normal View History

class SessionsController < ApplicationController
def new; end
def create
user = find_user
if user
self.current_user = user
2013-10-22 15:26:36 +00:00
redirect_back_or_to root_url, :notice => "Welcome back!"
else
store[:new_user_email] = omniauth_credentials.email
2013-10-19 16:25:30 +00:00
redirect_to new_user_path
2012-03-05 23:25:21 +00:00
end
end
def destroy
self.current_user = nil
2013-10-22 15:26:36 +00:00
redirect_to root_path, :notice => "See you later!"
end
def failure
redirect_to root_path, :alert => "Authentication failed. Maybe try again?"
end
private
def store
session
2012-03-10 13:58:10 +00:00
end
def find_user
User.for_email(omniauth_credentials.email)
2013-10-19 16:25:30 +00:00
end
end