Use controller method for 404 responses
This commit is contained in:
@ -12,6 +12,7 @@ class ApplicationController < ActionController::Base
|
||||
before_action :set_sentry_context, :load_embed_options
|
||||
protect_from_forgery(with: :exception, prepend: true)
|
||||
rescue_from Pundit::NotAuthorizedError, with: :render_not_authorized
|
||||
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
|
||||
rescue_from ActionController::InvalidAuthenticityToken, with: :render_csrf_error
|
||||
|
||||
def current_user
|
||||
@ -68,6 +69,15 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
private :render_not_authorized
|
||||
|
||||
def render_not_found
|
||||
if current_user&.admin?
|
||||
render_error t('application.not_found'), :not_found
|
||||
else
|
||||
render_not_authorized
|
||||
end
|
||||
end
|
||||
private :render_not_authorized
|
||||
|
||||
def render_error(message, status)
|
||||
set_sentry_context
|
||||
respond_to do |format|
|
||||
|
Reference in New Issue
Block a user