spree_auth_devise 3.2.0.beta → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +17 -6
- data/.travis.yml +19 -7
- data/Appraisals +13 -0
- data/CHANGELOG.md +11 -3
- data/Gemfile +1 -0
- data/README.md +30 -27
- data/Rakefile +1 -1
- data/app/mailers/spree/user_mailer.rb +6 -6
- data/app/models/spree/auth_configuration.rb +3 -3
- data/app/models/spree/user.rb +17 -16
- data/app/overrides/auth_shared_login_bar.rb +6 -7
- data/config.ru +1 -1
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/warden.rb +2 -2
- data/config/locales/bg.yml +54 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/it.yml +2 -2
- data/config/locales/nl.yml +1 -1
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/pt.yml +1 -1
- data/config/locales/tr.yml +1 -1
- data/config/routes.rb +17 -18
- data/db/default/users.rb +6 -6
- data/db/migrate/20101026184949_create_users.rb +14 -9
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +6 -1
- data/db/migrate/20101214150824_convert_user_remember_field.rb +6 -1
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +6 -1
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +8 -3
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +6 -1
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +6 -1
- data/db/migrate/20150416152553_add_missing_indices_on_user.rb +6 -1
- data/gemfiles/spree_3_1.gemfile +7 -0
- data/gemfiles/spree_3_2.gemfile +8 -0
- data/gemfiles/spree_master.gemfile +8 -0
- data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +6 -8
- data/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +15 -14
- data/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb +1 -1
- data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +9 -8
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +6 -1
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +22 -16
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +17 -16
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +4 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +5 -1
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +4 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +18 -11
- data/lib/controllers/frontend/spree/users_controller.rb +16 -15
- data/lib/generators/spree/auth/install/install_generator.rb +8 -2
- data/lib/spree/auth/devise.rb +1 -1
- data/lib/spree/auth/engine.rb +9 -9
- data/lib/tasks/auth.rake +1 -1
- data/lib/views/frontend/spree/users/show.html.erb +1 -1
- data/spec/controllers/spree/checkout_controller_spec.rb +1 -2
- data/spec/controllers/spree/products_controller_spec.rb +0 -1
- data/spec/controllers/spree/user_passwords_controller_spec.rb +3 -4
- data/spec/controllers/spree/user_registrations_controller_spec.rb +0 -1
- data/spec/controllers/spree/user_sessions_controller_spec.rb +0 -1
- data/spec/controllers/spree/users_controller_spec.rb +0 -1
- data/spec/factories/confirmed_user.rb +1 -1
- data/spec/features/account_spec.rb +0 -1
- data/spec/features/admin/orders_spec.rb +0 -1
- data/spec/features/admin/password_reset_spec.rb +0 -1
- data/spec/features/admin/products_spec.rb +0 -1
- data/spec/features/admin/sign_in_spec.rb +0 -1
- data/spec/features/admin/sign_out_spec.rb +0 -1
- data/spec/features/admin_permissions_spec.rb +0 -1
- data/spec/features/change_email_spec.rb +0 -1
- data/spec/features/checkout_spec.rb +8 -8
- data/spec/features/confirmation_spec.rb +1 -1
- data/spec/features/order_spec.rb +0 -1
- data/spec/features/password_reset_spec.rb +0 -1
- data/spec/features/sign_in_spec.rb +1 -2
- data/spec/features/sign_out_spec.rb +0 -1
- data/spec/features/sign_up_spec.rb +0 -1
- data/spec/mailers/user_mailer_spec.rb +0 -1
- data/spec/models/order_spec.rb +0 -1
- data/spec/models/user_spec.rb +3 -1
- data/spec/spec_helper.rb +0 -7
- data/spec/support/ability.rb +1 -1
- data/spec/support/authentication_helpers.rb +2 -2
- data/spec/support/capybara.rb +1 -1
- data/spec/support/confirm_helpers.rb +1 -1
- data/spec/support/database_cleaner.rb +2 -3
- data/spec/support/spree.rb +0 -16
- data/spree_auth_devise.gemspec +6 -6
- metadata +16 -13
- data/Versionfile +0 -5
- data/circle.yml +0 -13
@@ -18,23 +18,24 @@ Spree::CheckoutController.class_eval do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
|
-
def order_params
|
22
|
-
params[:order] ? params.require(:order).permit(:email) : {}
|
23
|
-
end
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
def order_params
|
23
|
+
params[:order].present? ? params.require(:order).permit(:email) : {}
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def skip_state_validation?
|
27
|
+
%w(registration update_registration).include?(params[:action])
|
28
|
+
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
def check_authorization
|
31
|
+
authorize!(:edit, current_order, cookies.signed[:guest_token])
|
32
|
+
end
|
33
|
+
|
34
|
+
# Introduces a registration step whenever the +registration_step+ preference is true.
|
35
|
+
def check_registration
|
36
|
+
return unless Spree::Auth::Config[:registration_step]
|
37
|
+
return if spree_current_user || current_order.email
|
38
|
+
store_location
|
39
|
+
redirect_to spree.checkout_registration_path
|
40
|
+
end
|
40
41
|
end
|
@@ -11,4 +11,8 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
|
|
11
11
|
def after_confirmation_path_for(resource_name, resource)
|
12
12
|
signed_in?(resource_name) ? signed_in_root_path(resource) : spree.login_path
|
13
13
|
end
|
14
|
+
|
15
|
+
def translation_scope
|
16
|
+
'devise.confirmations'
|
17
|
+
end
|
14
18
|
end
|
@@ -18,7 +18,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
18
18
|
|
19
19
|
if resource.errors.empty?
|
20
20
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
21
|
-
respond_with resource, :
|
21
|
+
respond_with resource, location: spree.login_path
|
22
22
|
else
|
23
23
|
respond_with_navigational(resource) { render :new }
|
24
24
|
end
|
@@ -40,6 +40,10 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
40
40
|
|
41
41
|
protected
|
42
42
|
|
43
|
+
def translation_scope
|
44
|
+
'devise.user_passwords'
|
45
|
+
end
|
46
|
+
|
43
47
|
def new_session_path(resource_name)
|
44
48
|
spree.send("new_#{resource_name}_session_path")
|
45
49
|
end
|
@@ -16,9 +16,9 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
16
16
|
redirect_back_or_default(after_sign_in_path_for(spree_current_user))
|
17
17
|
}
|
18
18
|
format.js {
|
19
|
-
render :
|
20
|
-
:
|
21
|
-
:
|
19
|
+
render json: { user: spree_current_user,
|
20
|
+
ship_address: spree_current_user.ship_address,
|
21
|
+
bill_address: spree_current_user.bill_address }.to_json
|
22
22
|
}
|
23
23
|
end
|
24
24
|
else
|
@@ -28,19 +28,26 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
28
28
|
render :new
|
29
29
|
}
|
30
30
|
format.js {
|
31
|
-
render :
|
31
|
+
render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity
|
32
32
|
}
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
protected
|
38
|
+
|
39
|
+
def translation_scope
|
40
|
+
'devise.user_sessions'
|
41
|
+
end
|
42
|
+
|
37
43
|
private
|
38
|
-
def accurate_title
|
39
|
-
Spree.t(:login)
|
40
|
-
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
def accurate_title
|
46
|
+
Spree.t(:login)
|
47
|
+
end
|
48
|
+
|
49
|
+
def redirect_back_or_default(default)
|
50
|
+
redirect_to(session["spree_user_return_to"] || default)
|
51
|
+
session["spree_user_return_to"] = nil
|
52
|
+
end
|
46
53
|
end
|
@@ -28,29 +28,30 @@ class Spree::UsersController < Spree::StoreController
|
|
28
28
|
if params[:user][:password].present?
|
29
29
|
# this logic needed b/c devise wants to log us out after password changes
|
30
30
|
user = Spree::User.reset_password_by_token(params[:user])
|
31
|
-
sign_in(@user, :
|
31
|
+
sign_in(@user, event: :authentication, bypass: !Spree::Auth::Config[:signout_after_password_change])
|
32
32
|
end
|
33
|
-
redirect_to spree.account_url, :
|
33
|
+
redirect_to spree.account_url, notice: Spree.t(:account_updated)
|
34
34
|
else
|
35
35
|
render :edit
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
40
|
-
def user_params
|
41
|
-
params.require(:user).permit(Spree::PermittedAttributes.user_attributes)
|
42
|
-
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
41
|
+
def user_params
|
42
|
+
params.require(:user).permit(Spree::PermittedAttributes.user_attributes)
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
def load_object
|
46
|
+
@user ||= spree_current_user
|
47
|
+
authorize! params[:action].to_sym, @user
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
def authorize_actions
|
51
|
+
authorize! params[:action].to_sym, Spree::User.new
|
52
|
+
end
|
53
|
+
|
54
|
+
def accurate_title
|
55
|
+
Spree.t(:my_account)
|
56
|
+
end
|
56
57
|
end
|
@@ -2,8 +2,10 @@ module Spree
|
|
2
2
|
module Auth
|
3
3
|
module Generators
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
|
+
class_option :migrate, type: :boolean, default: true, banner: 'Migrate the database'
|
6
|
+
|
5
7
|
def self.source_paths
|
6
|
-
paths =
|
8
|
+
paths = superclass.source_paths
|
7
9
|
paths << File.expand_path('../templates', __FILE__)
|
8
10
|
paths.flatten
|
9
11
|
end
|
@@ -22,7 +24,11 @@ module Spree
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def run_migrations
|
25
|
-
|
27
|
+
if options[:migrate]
|
28
|
+
run 'bundle exec rake db:migrate VERBOSE=false'
|
29
|
+
else
|
30
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
end
|
data/lib/spree/auth/devise.rb
CHANGED
data/lib/spree/auth/engine.rb
CHANGED
@@ -7,11 +7,11 @@ module Spree
|
|
7
7
|
isolate_namespace Spree
|
8
8
|
engine_name 'spree_auth'
|
9
9
|
|
10
|
-
initializer "spree.auth.environment", :
|
10
|
+
initializer "spree.auth.environment", before: :load_config_initializers do |_app|
|
11
11
|
Spree::Auth::Config = Spree::AuthConfiguration.new
|
12
12
|
end
|
13
13
|
|
14
|
-
initializer "spree_auth_devise.set_user_class", :
|
14
|
+
initializer "spree_auth_devise.set_user_class", after: :load_config_initializers do
|
15
15
|
Spree.user_class = "Spree::User"
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ module Spree
|
|
20
20
|
puts "[WARNING] You are not setting Devise.secret_key within your application!"
|
21
21
|
puts "You must set this in config/initializers/devise.rb. Here's an example:"
|
22
22
|
puts " "
|
23
|
-
puts %
|
23
|
+
puts %{Devise.secret_key = "#{SecureRandom.hex(50)}"}
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -49,24 +49,24 @@ module Spree
|
|
49
49
|
ApplicationController.send :include, Spree::AuthenticationHelpers
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.
|
53
|
-
@@
|
52
|
+
def self.api_available?
|
53
|
+
@@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
|
54
54
|
end
|
55
55
|
|
56
|
-
def self.
|
57
|
-
@@
|
56
|
+
def self.backend_available?
|
57
|
+
@@backend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Backend::Engine')
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.frontend_available?
|
61
61
|
@@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
|
62
62
|
end
|
63
63
|
|
64
|
-
if
|
64
|
+
if backend_available?
|
65
65
|
paths["app/controllers"] << "lib/controllers/backend"
|
66
66
|
paths["app/views"] << "lib/views/backend"
|
67
67
|
end
|
68
68
|
|
69
|
-
if
|
69
|
+
if frontend_available?
|
70
70
|
paths["app/controllers"] << "lib/controllers/frontend"
|
71
71
|
paths["app/views"] << "lib/views/frontend"
|
72
72
|
end
|
data/lib/tasks/auth.rake
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
<tr>
|
28
28
|
<td class="order-number"><%= link_to order.number, order_url(order) %></td>
|
29
29
|
<td class="order-date"><%= l order.completed_at.to_date %></td>
|
30
|
-
<td class="order-status"><%= Spree.t("
|
30
|
+
<td class="order-status"><%= Spree.t("order_states.#{order.state}").titleize %></td>
|
31
31
|
<td class="order-payment-state"><%= Spree.t("payment_states.#{order.payment_state}").titleize if order.payment_state %></td>
|
32
32
|
<td class="order-shipment-state"><%= Spree.t("shipment_states.#{order.shipment_state}").titleize if order.shipment_state %></td>
|
33
33
|
<td class="lead text-primary order-total"><%= order.display_total %></td>
|
@@ -1,5 +1,4 @@
|
|
1
1
|
RSpec.describe Spree::CheckoutController, type: :controller do
|
2
|
-
|
3
2
|
let(:order) { create(:order_with_totals, email: nil, user: nil) }
|
4
3
|
let(:user) { build(:user, spree_api_key: 'fake') }
|
5
4
|
let(:token) { 'some_token' }
|
@@ -114,7 +113,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
114
113
|
controller.stub :check_authorization
|
115
114
|
order.stub update_attributes: true
|
116
115
|
controller.should_not_receive :check_registration
|
117
|
-
spree_put :update_registration, { order: {
|
116
|
+
spree_put :update_registration, { order: {} }
|
118
117
|
end
|
119
118
|
|
120
119
|
it 'renders the registration view if unable to save' do
|
@@ -1,5 +1,4 @@
|
|
1
1
|
RSpec.describe Spree::UserPasswordsController, type: :controller do
|
2
|
-
|
3
2
|
let(:token) { 'some_token' }
|
4
3
|
|
5
4
|
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
|
@@ -16,7 +15,7 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
16
15
|
it 'flashes an error' do
|
17
16
|
spree_get :edit
|
18
17
|
expect(flash[:alert]).to include(
|
19
|
-
"You can't access this page without coming from a password reset "
|
18
|
+
"You can't access this page without coming from a password reset " \
|
20
19
|
'email'
|
21
20
|
)
|
22
21
|
end
|
@@ -34,9 +33,9 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
34
33
|
context 'when updating password with blank password' do
|
35
34
|
it 'shows error flash message, sets spree_user with token and re-displays password edit form' do
|
36
35
|
spree_put :update, { spree_user: { password: '', password_confirmation: '', reset_password_token: token } }
|
37
|
-
expect(assigns(:spree_user).
|
36
|
+
expect(assigns(:spree_user).is_a?(Spree::User)).to eq true
|
38
37
|
expect(assigns(:spree_user).reset_password_token).to eq token
|
39
|
-
expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :
|
38
|
+
expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user])
|
40
39
|
expect(response).to render_template :edit
|
41
40
|
end
|
42
41
|
end
|
@@ -47,9 +47,9 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
47
47
|
str_addr = 'bill_address'
|
48
48
|
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
49
49
|
%w(firstname lastname address1 city zipcode phone).each do |field|
|
50
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with:
|
50
|
+
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
51
51
|
end
|
52
|
-
select
|
52
|
+
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
53
53
|
check 'order_use_billing'
|
54
54
|
|
55
55
|
click_button 'Save and Continue'
|
@@ -77,9 +77,9 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
77
77
|
str_addr = 'bill_address'
|
78
78
|
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
79
79
|
%w(firstname lastname address1 city zipcode phone).each do |field|
|
80
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with:
|
80
|
+
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
81
81
|
end
|
82
|
-
select
|
82
|
+
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
83
83
|
check 'order_use_billing'
|
84
84
|
|
85
85
|
click_button 'Save and Continue'
|
@@ -118,9 +118,9 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
118
118
|
str_addr = 'bill_address'
|
119
119
|
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
120
120
|
%w(firstname lastname address1 city zipcode phone).each do |field|
|
121
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with:
|
121
|
+
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
122
122
|
end
|
123
|
-
select
|
123
|
+
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
124
124
|
check 'order_use_billing'
|
125
125
|
|
126
126
|
click_button 'Save and Continue'
|
@@ -145,9 +145,9 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
145
145
|
str_addr = 'bill_address'
|
146
146
|
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
147
147
|
%w(firstname lastname address1 city zipcode phone).each do |field|
|
148
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with:
|
148
|
+
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
149
149
|
end
|
150
|
-
select
|
150
|
+
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
151
151
|
check 'order_use_billing'
|
152
152
|
|
153
153
|
click_button 'Save and Continue'
|