omniauth strategy

This commit is contained in:
Zachary Chai
2016-10-17 14:26:31 -04:00
parent c32b48213a
commit 0d73a77f1f
10 changed files with 99 additions and 2 deletions

View File

@ -0,0 +1,17 @@
class SessionsController < ApplicationController
def create
@user = User.from_omniauth(request.env['omniauth.auth'])
session[:user_id] = @user.id
rescue => e
logger.error "Error authenticating via omniauth: #{e}"
ensure
redirect_to root_path
end
def destroy
if current_user
session.delete(:user_id)
end
redirect_to root_path
end
end