Start with a Rails app with authentication via Persona, Foundation CSS

This commit is contained in:
Andreas Haller 2014-11-19 17:07:05 +01:00
parent 9ac52066b4
commit 7cd9f207f5
72 changed files with 2586 additions and 0 deletions

View file

@ -0,0 +1,15 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def current_user
User.find(session[:user_id]) if session[:user_id].present?
end
def signed_in?
!!current_user
end
helper_method :current_user, :signed_in?
end

View file

View file

@ -0,0 +1,4 @@
class SearchController < ApplicationController
def index
end
end

View file

@ -0,0 +1,19 @@
class SessionsController < ApplicationController
def create
if user = User.find_or_create_from_auth_hash(auth_hash)
session[:user_id] = user.id
end
redirect_to root_path
end
def destroy
reset_session
redirect_to root_path
end
protected
def auth_hash
request.env['omniauth.auth']
end
end