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

Already on GitHub? Sign in to your account

Fixes spree custom user generator #1618

Closed
wants to merge 225 commits into
from

Conversation

Projects
None yet

tvdeyen commented Jun 1, 2012

Having a vanilla rails app with no spree initializer in it the spree::custom_user generator fails with file not found error.

This fixes this by creating a spree initializer if no one is present, otherwise appending to it.

radar added some commits May 8, 2012

@radar radar Rip out auth component, provide facilities for custom authentication af7803d
@radar radar Add authorize_admin hook to Admin::BaseController
This is so the admin section is disabled *by default*
0f50d61
@radar radar user_class method inside Spree module should be defined as a module m…
…ethod
48d8ed5
@radar radar Add spree/shared/unauthorized view 4678bfc
@radar radar Define a spree_login_path method in BaseController that is overridable a134193
@radar radar Don't do permission checking in ability.rb if user obj does not respo…
…nd to has_spree_role? method
863fa90
@radar radar Default current_spree_user to nil when user_class or current_user_met…
…hod not provided
8fa39a6
@radar radar Replace references to current_user with current_spree_user f0d9874
@radar radar Replace two more occurrences of current_user with current_spree_user
orders/show
shipments/edit
d0f9df2
@radar radar Make current_spree_user a helper_method f3584a0
@radar radar Move current_ability, current_spree_user and unauthorized methods int…
…o ControllerHelpers.

This is so these methods are available for places, such as Spree::UserRegistrationsController inside spree_auth_devise that don't inherit from Spree::BaseController but do include Spree::Core::ControllerHelpers
b9d03a9
@radar radar Correct call to helper_method inside ControllerHelpers 8a01c41
@radar radar Remove instantiate_controller_and_action_names from ControllerHelpers
What was this even doing? Just use params[:action] and params[:controller] instead.
dd698cb
@radar radar Add store_location to controller_helpers, define spree_signup_path an…
…d spree_logout_path methods that can be overridden
0c94dd3
@radar radar spree_login_path, spree_signup_path and spree_logout_path methods nee…
…d to be inside of an auth extension, as they are particular to that
3a0566c
@radar radar Rename current_spree_user to spree_current_user to keep it in line wi…
…th all other auth methods
8386d86
@radar radar Fix one more occurrences of current_spree_user in orders/show c45cf9f
@radar radar Remove current_user_method
It is better to simply define a spree_current_user method by using a decorator inside the auth extension, than defining it arbitrarily inside an initializer. The login_path, logout_path and sign_in_path methods are already supposed to be in a decorator, so this can join it
6d9363a
@radar radar Add auth-take-two to Travis 48b1d2e
@radar radar Remove auth from install script and Rake tasks a5d61f9
@radar radar Remove auth from travis 9fea502
@radar radar Remove spree_auth as a dependency of api 25efc16
@radar radar Call has_spree_role? method on current_api_user in api's base_controller b9b74b2
@radar radar Define has_spree_role? dummy method on Spree::User be2ce64
@radar radar Correct script/rails file in core
It was generating things inside of spec/dummy, which is wrong
a2bfcf8
@radar radar Add Spree::Core::TokenResource
This was taken from the auth component of Spree, but really belongs in Core as it is an AUTHORIZATION thing, and not an AUTHENTICATION thing
53d964f
@radar radar Fix script/rails in API 41c51c9
@radar radar Include Spree::TokenResource into ActiveRecord::Base at end of token_…
…resource.rb
7ea1cf0
@radar radar Use correct module in token_resource 7338de3
@radar radar Add TokenResource spec e1db14d
@radar radar Correct prefix tokenized_permissions table with spree_ c70da69
@radar radar [api] use has_spree_role, not has_role? in orders_controller b51ed4b
@radar radar [api] Add roles association and override for has_spree_role? method t…
…o User decorator
5957be7
@radar radar [api] Stub has_spree_role? not has_role? in sign_in_as_admin! helper 6ee8d0d
@radar radar Add initializer to dummy app that sets Spree.user_class f9618f2
@radar radar Use correct class in TokenResource spec 5fb3a5c
@radar radar Remove useless db/sample directory
It contained the users.rb file which was commented out
0f2a86e
@radar radar Due to changes in #1504, permalinks that share similar names to other…
… permalinks may now have numbers suffixed or incremented higher than expected to avoid potential conflicts
30bc818
@radar radar There is no more spree_auth for dash to rely on bfaed51
@radar radar Hack around not being able to sign in as a user in analytics_spec 84dac82
@radar radar No more auth for promo to rely on either 754b6fd
@radar radar Add roles association to User for dash 02a40bb
@radar radar Add roles association to User for promo 8a3dc04
@radar radar Remove mention of spree_auth assets from spree_promo assets 633d86f
@radar radar remove authentication helpers from dash 0dc586d
@radar radar Remove authentication helpers form promo a927960
@radar radar No longer link orders to anonymous users. Every order must have a val…
…id email address associated with it
059fcc9
@radar radar Prompt for email address on checkout page if one is not already provided eb0e5a5
@radar radar Use Spree.user_class in Spree::Promotion::Rules::User eb020f5
@radar radar Remove sign up spec from promotion adjustments and switch over from u…
…sing sign_in_as! now that auth is gone
cbd0a96
@radar radar Add question asking if user wants default authentication (spree_auth_…
…devise)
8d77c7a
@radar radar Remove Auth::Engine seed loading from install generator 2c74185
@radar radar [petty] fix spacing for inside call in cmd/installer 36a6253
@radar radar Default Spree.user_class in config/initializers/spree.rb 5d26f24
@radar radar Remove Spree::Auth::Engine mounting in rails/routes template for sandbox 875fb9d
@radar radar only mount core inside sandbox routes e02c276
@radar radar Revert "Remove Auth::Engine seed loading from install generator"
This reverts commit 2c74185.

If the user says "yes please install the default auth", we still want
the default users created.
ed5182b
@radar radar Use radar's copy of spree_auth_devise until it is made official 45b36e5
@radar radar Remove initializer from custom_user generator
This is actually taken care of inside the spree.rb initializer now
b7cf532
@radar radar Add checks for Spree.user_class to api, dash and promo user decorators e15009e

radar added some commits May 29, 2012

@radar radar [promo] Specify table name for roles association in user decorator 58f40cb
@radar radar [promo] Use join_table, not join_table name in user decorator 1093674
@radar radar Remove Admin::UsersController
Moved banner functionality to Admin::BannersController
3d496ce
@radar radar Remove call to spree.admin_users_path in spree/admin/shared/_head 871d045
@radar radar Remove users tab from spree/admin/shared/_tabs.html.erb 04b27dd
@radar radar Remove Users tab testing in admin/homepage_spec 9c7f056
@radar radar Remove users request spec 13c3d97
@radar radar [api] Remove users_controller_decorator
Developers will now need to add this themselves, or use an authentication extension which already provides it
177977d
@radar radar [promo] make actions/create_line_items specs not depend on database o…
…rdering

See broken build #1419.6 for the problems this caused in the past
e21ef54
@radar radar [promo] stop depending on DB order in promotion_adjustments's spec 39f19c8
@radar radar Store location before redirecting in unauthorized no-user situation 2512bb9
@radar radar Controllers always responds to spree_current_user
Due to method definition inside ControllerHelpers
c86e12a
@radar radar Add authentication routes to disallowed_routes in store_location, only
if they exist
5fe4ce7
@radar radar Check for spree_user_signup in CheckoutController
This is now the event that will trigger spree.user.signup notification for FirstOrder promotion

This leads to a shorter syntax in authentication extension gems, while still preserving all of the same functionality. i.e. User signs up, gets credited with the promotion.
c04759a
@radar radar Clear session[:spree_user_signup] after we're finished with it 4c5e1e7
@radar radar variable name is authentication_routes, not authenticated_routes 911f410
@radar radar Fixed issue where :user was not being passed correct value to spree.u…
…ser.signup event
221a62b
@radar radar Remove 'Done' from sandbox output, as it just gets swallowed up by
bundle install
6909041
@radar radar [cmd] Remove automatic setup of admin user from installer 2d4a848
@radar radar Remove incorrect helper_method calls from authentication_helpers temp…
…late
ebd53cc
@radar radar Correct name of roles association in config/initializers/user_class_e…
…xtensions
b4c05ed
@radar radar No need for promo user decorator
This is because core/config/initializers/user_class_extensions now deals
with setting up the roles association
f2d0556
@radar radar Rename api_key field to spree_api_key
This is to stop it conflicting with a potentially similarly named field on Spree.user_class models
6106401
@radar radar Add orders association for Spree.user_class models f090c83
@radar radar Rename api_key to spree_api_key in custom_user migration too 62f76a9
@radar radar Correct roles association name in user factory 1512ccb
@radar radar Remove devise and cancan dependencies from spree_sample
Devise is now provided by authentication extensions, and cancan is a dependency of core now
edcc16b
@radar radar Use append_file rather than insert_into file for authentication_helpe…
…rs hook

It's not important that this is done before configuration, and therefore can go anywhere in the file

h/t beneggget
cfc4a34
@radar radar Fix issue where order was not being remembered
Fixes #1066
f440558
@radar radar Remove debug page! in checkout_spec fd288d3
@radar radar Add last_incomplete_spree_order to test doubles in checkout and produ…
…cts controller specs
04d38ff
@radar radar Need to include Spree::AuthenticationHelpers into ApplicationControll…
…er automatically
62f7d92
@radar radar Check for last_incomplete_order before setting session[:order_id] ins…
…ide set_current_order
e7a46e5
@radar radar Wrap product descriptions in paragraph tags only when there's a line
followed by two line breaks.

Fixes #1607
63c8839
@radar radar Move contents of Spree::Core::ControllerHelpers module into Spree::Ba…
…seController

This is so that the methods can be more easily overriden. Methods provided by a module cannot be overriden on what they are included into. For example, if Spree::BaseController kept including ControllerHelpers which was defining a spree_current_user method and an authentication extension attempted to override this method, it would not work. The method that would be called would be the dummy one included in ControllerHelpers.

It never made sense to me to have ControllerHelpers only being included in one place. Therefore, let's just throw everything in the BaseController so it's more obvious to people where things come from.

This will probably fix the issue where spree_current_user is nil on custom-auth apps
349d774
@radar radar Add spree/analytics helper to Spree::BaseController in to_prepare blo…
…ck for Spree::Dash::Engine
1deabd8
@radar radar Moved cancan require to spree/core, where all the other requires are cbdb3ad
@radar radar Actually remove inclusion of Spree::Core::ControllerHelpers, rather t…
…han just talking about it
96875e5
@radar radar move default_notification_payload into config.to_prepare, call it on …
…Spree::BaseController instead
463d307
@radar radar Add helper_method line for spree_current_user to authentication_helpers 8404a3a
@radar radar Include Spree::AuthenticationHelpers into Spree::BaseController also a353262
@radar radar Bump maximum Rails version to 3.2.4 dde7a0f
@radar radar Revert back to Rails 3.2.3
This is due to a number of regressions reported in Rails:

rails/rails#6576
rails/rails#6577

As well as a failing test inside of api brought on by rails/rails@ac465d5.

There is also the issue of link_to_function's deprecation in this version of Rails, which is still used in a couple of places in Spree.
d07f02c
@radar radar Namespace Taxonomy reference in Spree::BaseController
A user, beneggett, reported that sans-namespace reference was causing uninitialized constant Spree::BaseController::Taxonomy
b61fc62
@radar radar Add spree_current_user back to Spree::BaseController to make tests happy 28e9ffe
@radar radar Need to make spree_current_user a helper method also 0a7aaf9
Contributor

beneggett commented on 28e9ffe Jun 1, 2012

Made tests happy, made access to /admin area break...resulting in redirect loop again.

It seems this is not being overridden as hoped by the spree/auth_helper.

Member

radar replied Jun 1, 2012

Providing a proxy method called current_user which will now be used within spree to reference the current user. This will reference spree_current_user if it exists, or nil if it doesn't.

tvdeyen commented Jun 1, 2012

F*#$!!
Sorry !

@tvdeyen tvdeyen closed this Jun 1, 2012

tvdeyen commented Jun 1, 2012

I don't know what went wrong. I fetched your branch and made a feature branch, like usually, but sometimes git makes you say WAT?

The commit fixing this issue is 12a10ab

tvdeyen commented Jun 1, 2012

Ah, I see I messed up the branches. I should have sent to auth-take-two.

Sorry about that!

@mamhoff mamhoff deleted the magiclabs:fixes-spree-custom-user-generator branch Feb 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment