mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Add handling of PaperTrail.whodunnit to Registrant API controllers
This commit is contained in:
parent
07072ec6cb
commit
3ee5291b57
4 changed files with 23 additions and 12 deletions
|
@ -6,6 +6,7 @@ module Api
|
|||
module Registrant
|
||||
class BaseController < ActionController::API
|
||||
before_action :authenticate
|
||||
before_action :set_paper_trail_whodunnit
|
||||
|
||||
rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception|
|
||||
error = {}
|
||||
|
@ -41,6 +42,12 @@ module Api
|
|||
render json: { errors: [{base: ['Not authorized']}] }, status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
# This controller does not inherit from ApplicationController,
|
||||
# so user_for_paper_trail method is not usable.
|
||||
def set_paper_trail_whodunnit
|
||||
::PaperTrail.whodunnit = current_user.id_role_username
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue