aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/chouette_controller.rb1
-rw-r--r--app/controllers/concerns/paper_trail_support.rb11
3 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6a9f6942f..97f5548ae 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,5 +1,7 @@
class ApplicationController < ActionController::Base
+ include PaperTrailSupport
include Pundit
+
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
# TODO : Delete hack to authorize Cross Request for js and json get request from javascript
diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb
index e6e7c0a8a..3e4f3af27 100644
--- a/app/controllers/chouette_controller.rb
+++ b/app/controllers/chouette_controller.rb
@@ -1,3 +1,4 @@
class ChouetteController < InheritedResources::Base
+ include PaperTrailSupport
include ApplicationHelper
end
diff --git a/app/controllers/concerns/paper_trail_support.rb b/app/controllers/concerns/paper_trail_support.rb
new file mode 100644
index 000000000..4b0b1a7c7
--- /dev/null
+++ b/app/controllers/concerns/paper_trail_support.rb
@@ -0,0 +1,11 @@
+module PaperTrailSupport
+ extend ActiveSupport::Concern
+
+ included do
+ before_action :set_paper_trail_whodunnit
+
+ def user_for_paper_trail
+ current_user ? current_user.name : ''
+ end
+ end
+end