Advertisement
saasbook

sessions_controller.rb

Jan 9th, 2013
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.50 KB | None | 0 0
  1. class SessionsController < ApplicationController
  2.   # user shouldn't have to be logged in before logging in!
  3.   skip_before_filter :set_current_user
  4.   def create
  5.     auth=request.env["omniauth.auth"]
  6.     user=Moviegoer.find_by_provider_and_uid(auth["provider"],auth["uid"]) ||
  7.       Moviegoer.create_with_omniauth(auth)
  8.     session[:user_id] = user.id
  9.     redirect_to movies_path
  10.   end
  11.   def destroy
  12.     session.delete(:user_id)
  13.     flash[:notice] = 'Logged out successfully.'
  14.     redirect_to movies_path
  15.   end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement