add rails-footnotes
omni initializers
create uid, provider colomns
test seed
session
omni identity
sessions controller
[from now] 2013/07/28 11:19:14

diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index f8a2b61..0a85a2c 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,8 +1,12 @@
 class SessionsController < ApplicationController
   def create
-    require 'pry-remote'; binding.pry_remote
+    user = User.from_omniauth(env["omniauth.auth"])
+    session[:user_id] = user.id
+    redirect_to root_url, notice: "Signed in!"
   end

   def destory
+    session[:user_id] = nil
+    redirect_to root_url, notice: "Signed out!"
   end
 end
[from now] 2013/07/28 11:21:55

diff --git a/app/models/user.rb b/app/models/user.rb
index 1937adb..933ccf5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,3 +1,16 @@
 class User < ActiveRecord::Base
   has_many :reviews, foreign_key: 'author_id'
+
+  def self.from_omniauth(auth)
+    user = where(auth.slice('provider', 'uid')).first || create_from_omniauth(auth)
+    user
+  end
+
+  def self.create_from_omniauth(auth)
+    create! do |user|
+      user.provider = auth['provider']
+      user.uid = auth['uid']
+      user.name = auth['info']['nickname']
+    end
+  end
 end
diff --git a/config/application.rb b/config/application.rb
index 6e77bca..602df9d 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -11,6 +11,8 @@ require "sprockets/railtie"
 # you've limited to :test, :development, or :production.
 Bundler.require(:default, Rails.env)

+Dotenv.load
+
 module Gourmet
   class Application < Rails::Application
     # Settings in config/environments/* take precedence over those specified here.
[from now] 2013/07/28 11:24:23

diff --git a/config/routes.rb b/config/routes.rb
index e4a0289..5ff7e67 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,13 +1,13 @@
 Gourmet::Application.routes.draw do
-  get "sessions/create"
-  get "sessions/destory"
   controller :sessions do
     get '/auth/:provider/callback' => :create
     get '/logout' => :destroy, as: :logout
   end

-  post '/auth/developer/callback', to: 'sessions#create' if Rails.env.development?
   resources :reviews
+
+  root 'reviews#index'
+
   # The priority is based upon order of creation: first created -> highest priority.
   # See how all your routes lay out with "rake routes".
implement login, etc