add logger for all auth operations + fix a bug when retrieving a content entry from its _id in MongoDB

did committed Nov 17, 2016
commit d1f77ceb9a9e63da6c06f7f712a01bd05bbb6ca2
Showing 2 changed files with 7 additions and 3 deletions
locomotive/steam/middlewares/auth.rb b/lib/locomotive/steam/middlewares/auth.rb +6 -2
@@ @@ -85,13 +85,17 @@ module Locomotive::Steam
def store_authenticated(entry)
type = entry ? entry.content_type.slug : request.session[:authenticated_entry_type]
- request.session[:authenticated_entry_type] = type
- request.session[:authenticated_entry_id] = entry.try(:_id)
+ request.session[:authenticated_entry_type] = type.to_s
+ request.session[:authenticated_entry_id] = entry.try(:_id).to_s
+
+ log "[Auth] authenticated #{type.to_s.singularize} ##{entry.try(:_id).to_s}"
liquid_assigns["current_#{type.singularize}"] = entry
end
def append_message(message)
+ log "[Auth] status message = #{message.inspect}"
+
message ||= 'error'
liquid_assigns["auth_#{message}"] = "auth_#{message}"
end
locomotive/steam/repositories/content_entry_repository.rb b/lib/locomotive/steam/repositories/content_entry_repository.rb +1 -1
@@ @@ -57,7 +57,7 @@ module Locomotive
end
def find(id)
- conditions, _ = conditions_without_order_by(_id: id)
+ conditions, _ = conditions_without_order_by(_id: self.adapter.make_id(id))
first { where(conditions) }
end