mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2025-04-20 07:11:33 +02:00
Start with a Rails app with authentication via Persona, Foundation CSS
This commit is contained in:
parent
9ac52066b4
commit
7cd9f207f5
72 changed files with 2586 additions and 0 deletions
15
app/controllers/application_controller.rb
Normal file
15
app/controllers/application_controller.rb
Normal 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
|
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
4
app/controllers/search_controller.rb
Normal file
4
app/controllers/search_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class SearchController < ApplicationController
|
||||
def index
|
||||
end
|
||||
end
|
19
app/controllers/sessions_controller.rb
Normal file
19
app/controllers/sessions_controller.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue