lib/shamu/rails/controller.rb in shamu-0.0.19 vs lib/shamu/rails/controller.rb in shamu-0.0.20
- old
+ new
@@ -19,16 +19,28 @@
# ActionController::API does not have #helper_method
if respond_to?( :helper_method )
helper_method :permit?
helper_method :current_user
end
+
+ # In `included` block so that it overrides Scorpion controller method.
+
+ def prepare_scorpion( scorpion )
+ super
+
+ scorpion.prepare do |s|
+ s.hunt_for Shamu::Security::Principal do
+ security_principal
+ end
+ end
+ end
end
private
# The currently logged in user. Must respond to #id when logged in.
- def current_user
+ def current_user_id
end
# @!visibility public
#
# @return [Array<Services::Service>] the list of services available to the
@@ -65,11 +77,11 @@
#
# @return [Shamu::Security::Principal]
def security_principal
@security_principal ||= begin
Shamu::Security::Principal.new \
- user_id: current_user && current_user.id,
+ user_id: current_user_id,
remote_ip: remote_ip,
elevated: session_elevated?
end
end
@@ -87,18 +99,9 @@
#
# @return [Boolean] true if the session has been elevated.
def session_elevated?
end
- def prepare_scorpion( scorpion )
- super
-
- scorpion.prepare do |s|
- s.hunt_for Shamu::Security::Principal do
- security_principal
- end
- end
- end
class_methods do
# @return [Array<Symbol>] the list of service names on the controller.
def services