Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include CamaleonCms::SessionHelper in global scope is unhealthy #9

Open
p-decoraid opened this issue Aug 29, 2016 · 2 comments
Open

Comments

@p-decoraid
Copy link

This:

https://github.com/owen2345/camaleon_oauth/blob/master/config/initializers/doorkeeper.rb#L1

makes methods like current_user available in the global scope.

However, current_user invokes cama_calc_api_current_user which invokes doorkeeper_token. doorkeeper_token is not available in the global scope, hence current_user fails.

Furthermore, cama_current_user has a cache for the current user value - @cama_current_user. This is an instance variable which again is not accessible from the global scope.

Instead of putting methods into the global scope, specific classes or modules should include CamaleonCms::SessionHelper etc.

@owen2345
Copy link
Owner

This plugin was not updated since Camaleon_cms 1.x, if you can fix and update I will appreciate.
I think this plugin can be very useful for angularjs integration.
Regards,

@p-decoraid
Copy link
Author

I am trying to do that, however running into current_user being nil right now. The impression I get is that camaleon-oauth is overwriting some global state set up by camaleon-cms because I am able to check out using a test camaleon-cms installation with camaleon-ecommerce but without camaleon-oauth.

Here is a stack trace:

 - draper (2.1.0) lib/draper/helper_proxy.rb:35:in `block in define_proxy'
 - /home/oleg/apps/backend/vendor/cache/camaleon-cms-1d25088e16b3/app/helpers/camaleon_cms/session_helper.rb:144:in `cama_calc_api_current_user'
 - /home/oleg/apps/backend/vendor/cache/camaleon-cms-1d25088e16b3/app/helpers/camaleon_cms/session_helper.rb:110:in `cama_current_user'
 - /home/oleg/apps/backend/vendor/cache/camaleon-ecommerce-a8543f617be2/app/decorators/plugins/ecommerce/product_decorator.rb:108:in `the_qty_real'
 - /home/oleg/apps/backend/vendor/cache/camaleon-ecommerce-a8543f617be2/app/decorators/plugins/ecommerce/product_item_decorator.rb:34:in `decrement_qty!'
 - /home/oleg/apps/backend/vendor/cache/camaleon-ecommerce-a8543f617be2/app/models/plugins/ecommerce/cart.rb:82:in `block in make_order!'
 - draper (2.1.0) lib/draper/delegation.rb:10:in `each'
 - /home/oleg/apps/backend/vendor/cache/camaleon-ecommerce-a8543f617be2/app/models/plugins/ecommerce/cart.rb:82:in `make_order!'
 - /home/oleg/apps/backend/vendor/cache/camaleon-ecommerce-a8543f617be2/app/models/plugins/ecommerce/cart.rb:148:in `make_paid!'
 - draper (2.1.0) lib/draper/delegation.rb:10:in `make_paid!'
 - draper (2.1.0) lib/draper/automatic_delegation.rb:10:in `method_missing'
 - /home/oleg/apps/backend/vendor/cache/camaleon-ecommerce-a8543f617be2/app/helpers/plugins/ecommerce/ecommerce_email_helper.rb:5:in `mark_order_like_received'

How is mark_order_like_received/make_paid!/make_order! intended to make current_user work?

Here is something else related. prod is a Product instance in this mark_order_like_received etc. process:

(byebug) prod.current_user
#, @context={}>
(byebug) prod.cama_current_user
*** NoMethodError Exception: undefined method `cama_current_user' for #
nil

Where is the current_user method defined that ends up being on the product instance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants