You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method performs an order merge operation if there's more than one incomplete order for the user.
Unless I miss a use case, this correct behaviour is have this operation be performed only after a user login - exactly in UserSessionsController#create.
It is currently incorrectly executed there in a before_action instead of an after_action with the inclusion of the Order module.
I was wondering if anyone would have a recommendation on how to cleanly move the order merge logic in the create session operation, as stores could be using different gems for authentication.
One way is through registering after login hooks, like the self.update_hooks = Set.new on Order.rb, but it seems like too much of a change.
Edit, after having another look, it appears that you have already come up with a brilliant solution to that:
So, do you think it will be a good idea to tuck the Order#merge logic in there as well? I'm only not sure how to get the current_order from warden, but there must be a way.
@mvz - I'm pinging you as you were active on this area of the code recently.
Thank you!
The text was updated successfully, but these errors were encountered:
mtomov
changed the title
Remove order merge logic happening on every request.
Remove order merge logic happening on every request
May 6, 2016
This actually looks like a pretty reasonable approach to me. We will need to ensure that we have something friendly for non-auth-devise usage as well but I think its pretty low hanging fruit to remove every round trips from every request. Would be a good target for someone during the hack days next week, too...
Hello,
set_current_order is a method, which is called on every request and results in 3 sql queries for logged in users:
The method performs an order merge operation if there's more than one incomplete order for the user.
Unless I miss a use case, this correct behaviour is have this operation be performed only after a user login - exactly in UserSessionsController#create.
It is currently incorrectly executed there in a
before_action
instead of anafter_action
with the inclusion of theOrder
module.I was wondering if anyone would have a recommendation on how to cleanly move the order merge logic in the create session operation, as stores could be using different gems for authentication.- One way is through registering after login hooks, like the
self.update_hooks = Set.new
on Order.rb, but it seems like too much of a change.Edit, after having another look, it appears that you have already come up with a brilliant solution to that:
config/initializers/warden.rb
So, do you think it will be a good idea to tuck the Order#merge logic in there as well? I'm only not sure how to get the
current_order
from warden, but there must be a way.@mvz - I'm pinging you as you were active on this area of the code recently.
Thank you!
The text was updated successfully, but these errors were encountered: