pix pundit init and ad screenshots
This commit is contained in:
parent
550ad000d1
commit
564e073ada
1
Gemfile
1
Gemfile
|
@ -51,6 +51,7 @@ end
|
|||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'capybara-screenshot'
|
||||
gem 'launchy'
|
||||
gem 'selenium-webdriver'
|
||||
end
|
||||
|
|
|
@ -94,6 +94,9 @@ GEM
|
|||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
capybara-screenshot (1.0.11)
|
||||
capybara (>= 1.0, < 3)
|
||||
launchy
|
||||
childprocess (0.5.9)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
coderay (1.1.1)
|
||||
|
@ -353,6 +356,7 @@ DEPENDENCIES
|
|||
capistrano-rails
|
||||
capistrano-rails-console
|
||||
capybara
|
||||
capybara-screenshot
|
||||
coffee-rails (~> 4.1.0)
|
||||
database_cleaner
|
||||
devise
|
||||
|
|
|
@ -2,4 +2,21 @@ 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
|
||||
include Pundit
|
||||
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
||||
|
||||
def after_sign_in_path_for(resource_or_scope)
|
||||
current_user
|
||||
end
|
||||
|
||||
def after_sign_out_path_for(resource_or_scope)
|
||||
page_path(:camp)
|
||||
end
|
||||
|
||||
private
|
||||
def user_not_authorized
|
||||
flash[:alert] = "Access denied."
|
||||
redirect_to (request.referrer || root_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
# config/initializers/pundit.rb
|
||||
# Extends the ApplicationController to add Pundit for authorization.
|
||||
# Modify this file to change the behavior of a 'not authorized' error.
|
||||
# Be sure to restart your server when you modify this file.
|
||||
module PunditHelper
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include Pundit
|
||||
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_not_authorized
|
||||
flash[:alert] = "Access denied."
|
||||
redirect_to (request.referrer || root_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ApplicationController.send :include, PunditHelper
|
Loading…
Reference in New Issue