spree_auth_devise 4.1.0.rc1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +3 -12
- data/app/controllers/spree/user_confirmations_controller.rb +23 -1
- data/app/controllers/spree/user_registrations_controller.rb +18 -1
- data/app/views/spree/user_passwords/new.html.erb +2 -3
- data/config/locales/en.yml +3 -1
- data/config/routes.rb +2 -2
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +2 -2
- data/lib/controllers/frontend/spree/users_controller.rb +3 -3
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
- data/spec/controllers/spree/user_registrations_controller_spec.rb +1 -1
- data/spec/features/checkout_spec.rb +1 -1
- data/spec/features/confirmation_spec.rb +2 -2
- data/spec/features/sign_up_spec.rb +2 -2
- data/spec/models/user_spec.rb +5 -5
- data/spree_auth_devise.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7803bda30cc0ed9cca3df5b201c6f53e53ed57841dd26c18eecaad80888779e6
|
4
|
+
data.tar.gz: 615ee2f16b67ed9e082c55c2f3b011ffedd363f7ac83d392819ef6a8f24da7b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2fddae86244f213dcdb77ab7f4ef0658b8d9ca3255b43b7d3e53ca0f750479ce0b0d7b80ec59d7a820aa0f17ee670a5b6fd34a485b826681f73b0b972a484bd
|
7
|
+
data.tar.gz: ec8035b779912362315ada27d8ab6bc69152609e7776d155e7f14a8a2a4fa7920d0e0a89d16968b55cef5e018bcbe967cb70f767917c077915ed40b19cdf1672
|
data/README.md
CHANGED
@@ -10,20 +10,11 @@ Provides authentication services for [Spree](https://spreecommerce.org), using t
|
|
10
10
|
|
11
11
|
1. Add this extension to your Gemfile with this line:
|
12
12
|
|
13
|
-
#### Spree >= 3.1
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
gem 'spree_auth_devise', '~> 3.3'
|
17
|
-
```
|
18
|
-
|
19
|
-
#### Spree 3.0 and Spree 2.x
|
20
|
-
|
21
13
|
```ruby
|
22
|
-
gem 'spree_auth_devise'
|
14
|
+
gem 'spree_auth_devise'
|
23
15
|
```
|
24
|
-
|
25
|
-
|
26
|
-
For example, use `3-0-stable` if you're using Spree `3-0-stable` or any `3.0.x` version.
|
16
|
+
|
17
|
+
if you run into any version-mismatch problems please run `bundle update`
|
27
18
|
|
28
19
|
2. Install the gem using Bundler:
|
29
20
|
```ruby
|
@@ -7,7 +7,29 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
|
|
7
7
|
include Spree::Core::ControllerHelpers::Store
|
8
8
|
|
9
9
|
before_action :set_current_order
|
10
|
-
|
10
|
+
|
11
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
12
|
+
def show
|
13
|
+
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
14
|
+
yield resource if block_given?
|
15
|
+
|
16
|
+
if resource.errors.empty?
|
17
|
+
set_flash_message!(:notice, :confirmed)
|
18
|
+
respond_with_navigational(resource) do
|
19
|
+
redirect_to after_confirmation_path_for(resource_name, resource)
|
20
|
+
end
|
21
|
+
elsif resource.confirmed?
|
22
|
+
set_flash_message(:error, :already_confirmed)
|
23
|
+
respond_with_navigational(resource) do
|
24
|
+
redirect_to after_confirmation_path_for(resource_name, resource)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
respond_with_navigational(resource.errors, status: :unprocessable_entity) do
|
28
|
+
render :new
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
11
33
|
protected
|
12
34
|
|
13
35
|
def after_confirmation_path_for(resource_name, resource)
|
@@ -30,7 +30,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
30
30
|
set_flash_message :notice, :signed_up
|
31
31
|
sign_up(resource_name, resource)
|
32
32
|
session[:spree_user_signup] = true
|
33
|
-
|
33
|
+
redirect_to_checkout_or_account_path(resource)
|
34
34
|
else
|
35
35
|
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}"
|
36
36
|
expire_data_after_sign_in!
|
@@ -80,6 +80,13 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
80
80
|
after_sign_in_redirect(resource) if is_navigational_format?
|
81
81
|
end
|
82
82
|
|
83
|
+
def after_inactive_sign_up_path_for(resource)
|
84
|
+
scope = Devise::Mapping.find_scope!(resource)
|
85
|
+
router_name = Devise.mappings[scope].router_name
|
86
|
+
context = router_name ? send(router_name) : self
|
87
|
+
context.respond_to?(:login_path) ? context.login_path : "/login"
|
88
|
+
end
|
89
|
+
|
83
90
|
private
|
84
91
|
|
85
92
|
def spree_user_params
|
@@ -89,4 +96,14 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
89
96
|
def after_sign_in_redirect(resource_or_scope)
|
90
97
|
stored_location_for(resource_or_scope) || account_path
|
91
98
|
end
|
99
|
+
|
100
|
+
def redirect_to_checkout_or_account_path(resource)
|
101
|
+
resource_path = after_sign_up_path_for(resource)
|
102
|
+
|
103
|
+
if resource_path == spree.checkout_state_path(:address)
|
104
|
+
respond_with resource, location: spree.checkout_state_path(:address)
|
105
|
+
else
|
106
|
+
respond_with resource, location: spree.account_path
|
107
|
+
end
|
108
|
+
end
|
92
109
|
end
|
@@ -8,10 +8,9 @@
|
|
8
8
|
<div class="card-body">
|
9
9
|
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
10
10
|
|
11
|
-
<%= form_for Spree
|
11
|
+
<%= form_for Spree.user_class.new, as: :spree_user, url: spree.reset_password_path do |f| %>
|
12
12
|
<div class="form-group">
|
13
|
-
<%= f.
|
14
|
-
<%= f.email_field :email, class: "spree-flat-input" %>
|
13
|
+
<%= f.email_field :email, class: "spree-flat-input", placeholder: Spree.t(:email) %>
|
15
14
|
</div>
|
16
15
|
<div>
|
17
16
|
<%= f.submit Spree.t(:reset_password), class: 'btn btn-primary btn-block spree-btn mt-2' %>
|
data/config/locales/en.yml
CHANGED
@@ -9,6 +9,8 @@ en:
|
|
9
9
|
confirmations:
|
10
10
|
confirmed: Your account was successfully confirmed. You are now signed in.
|
11
11
|
send_instructions: You will receive an email with instructions about how to confirm your account in a few minutes.
|
12
|
+
spree_user:
|
13
|
+
already_confirmed: Email was already confirmed, please try signing in.
|
12
14
|
failure:
|
13
15
|
inactive: Your account was not activated yet.
|
14
16
|
invalid: Invalid email or password.
|
@@ -41,7 +43,7 @@ en:
|
|
41
43
|
user_registrations:
|
42
44
|
destroyed: Bye! Your account was successfully cancelled. We hope to see you again soon.
|
43
45
|
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
|
44
|
-
signed_up_but_unconfirmed:
|
46
|
+
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
|
45
47
|
signed_up: Welcome! You have signed up successfully.
|
46
48
|
updated: You updated your account successfully.
|
47
49
|
user_sessions:
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Spree::Core::Engine.add_routes do
|
2
2
|
devise_for :spree_user,
|
3
|
-
class_name:
|
3
|
+
class_name: Spree.user_class.to_s,
|
4
4
|
controllers: { sessions: 'spree/user_sessions',
|
5
5
|
registrations: 'spree/user_registrations',
|
6
6
|
passwords: 'spree/user_passwords',
|
@@ -31,7 +31,7 @@ Spree::Core::Engine.add_routes do
|
|
31
31
|
|
32
32
|
namespace :admin, path: Spree.admin_path do
|
33
33
|
devise_for :spree_user,
|
34
|
-
class_name:
|
34
|
+
class_name: Spree.user_class.to_s,
|
35
35
|
controllers: { sessions: 'spree/admin/user_sessions',
|
36
36
|
passwords: 'spree/admin/user_passwords' },
|
37
37
|
skip: [:unlocks, :omniauth_callbacks, :registrations],
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AddResetPasswordSentAtToSpreeUsers < SpreeExtension::Migration[4.2]
|
2
2
|
def change
|
3
|
-
Spree
|
4
|
-
unless Spree
|
3
|
+
Spree.user_class.reset_column_information
|
4
|
+
unless Spree.user_class.column_names.include?("reset_password_sent_at")
|
5
5
|
add_column :spree_users, :reset_password_sent_at, :datetime
|
6
6
|
end
|
7
7
|
end
|
@@ -6,7 +6,7 @@ module Spree::CheckoutControllerDecorator
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def registration
|
9
|
-
@user = Spree
|
9
|
+
@user = Spree.user_class.new
|
10
10
|
end
|
11
11
|
|
12
12
|
def update_registration
|
@@ -14,7 +14,7 @@ module Spree::CheckoutControllerDecorator
|
|
14
14
|
redirect_to spree.checkout_state_path(:address)
|
15
15
|
else
|
16
16
|
flash[:error] = t(:email_is_invalid, scope: [:errors, :messages])
|
17
|
-
@user = Spree
|
17
|
+
@user = Spree.user_class.new
|
18
18
|
render 'registration'
|
19
19
|
end
|
20
20
|
end
|
@@ -10,7 +10,7 @@ class Spree::UsersController < Spree::StoreController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
@user = Spree
|
13
|
+
@user = Spree.user_class.new(user_params)
|
14
14
|
if @user.save
|
15
15
|
|
16
16
|
if current_order
|
@@ -27,7 +27,7 @@ class Spree::UsersController < Spree::StoreController
|
|
27
27
|
if @user.update(user_params)
|
28
28
|
if params[:user][:password].present?
|
29
29
|
# this logic needed b/c devise wants to log us out after password changes
|
30
|
-
Spree
|
30
|
+
Spree.user_class.reset_password_by_token(params[:user])
|
31
31
|
if Spree::Auth::Config[:signout_after_password_change]
|
32
32
|
sign_in(@user, event: :authentication)
|
33
33
|
else
|
@@ -52,7 +52,7 @@ class Spree::UsersController < Spree::StoreController
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def authorize_actions
|
55
|
-
authorize! params[:action].to_sym, Spree
|
55
|
+
authorize! params[:action].to_sym, Spree.user_class.new
|
56
56
|
end
|
57
57
|
|
58
58
|
def accurate_title
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
7
7
|
|
8
|
-
<%= form_for Spree
|
8
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
|
9
9
|
<p>
|
10
10
|
<%= f.label :email, Spree.t(:email) %><br />
|
11
11
|
<%= f.email_field :email %>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<div data-hook="login" class="card border-0">
|
6
6
|
<div class="card-body">
|
7
|
-
<%= form_for Spree
|
7
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
|
8
8
|
<div id="password-credentials">
|
9
9
|
<div class="form-group text-center">
|
10
10
|
<%= f.label :email, Spree.t(:email) %>
|
@@ -25,7 +25,7 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
|
25
25
|
order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
|
26
26
|
end
|
27
27
|
post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }}
|
28
|
-
user = Spree
|
28
|
+
user = Spree.user_class.find_by_email('foobar@example.com')
|
29
29
|
|
30
30
|
order.reload
|
31
31
|
expect(order.user_id).to eq user.id
|
@@ -126,7 +126,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
126
126
|
click_button 'Save and Continue'
|
127
127
|
|
128
128
|
expect(page).to have_text 'Order placed successfully'
|
129
|
-
expect(Spree::Order.first.user).to eq Spree
|
129
|
+
expect(Spree::Order.first.user).to eq Spree.user_class.find_by_email('test@person.com')
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -20,7 +20,7 @@ RSpec.feature 'Confirmation', type: :feature, reload_user: true do
|
|
20
20
|
fill_in 'Password Confirmation', with: 'password'
|
21
21
|
click_button 'Sign Up'
|
22
22
|
|
23
|
-
expect(page).to have_text '
|
24
|
-
expect(Spree
|
23
|
+
expect(page).to have_text I18n.t('devise.user_registrations.signed_up_but_unconfirmed')
|
24
|
+
expect(Spree.user_class.last.confirmed?).to be(false)
|
25
25
|
end
|
26
26
|
end
|
@@ -10,7 +10,7 @@ RSpec.feature 'Sign Up', type: :feature do
|
|
10
10
|
click_button 'Sign Up'
|
11
11
|
|
12
12
|
expect(page).to have_text 'You have signed up successfully.'
|
13
|
-
expect(Spree
|
13
|
+
expect(Spree.user_class.count).to eq(1)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -25,7 +25,7 @@ RSpec.feature 'Sign Up', type: :feature do
|
|
25
25
|
click_button 'Sign Up'
|
26
26
|
|
27
27
|
expect(page).to have_css '#errorExplanation'
|
28
|
-
expect(Spree
|
28
|
+
expect(Spree.user_class.count).to eq(0)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -31,9 +31,9 @@ RSpec.describe Spree::User, type: :model do
|
|
31
31
|
order.save
|
32
32
|
user = order.user
|
33
33
|
user.destroy
|
34
|
-
expect(Spree
|
35
|
-
expect(Spree
|
36
|
-
expect(Spree
|
34
|
+
expect(Spree.user_class.find_by_id(user.id)).to be_nil
|
35
|
+
expect(Spree.user_class.with_deleted.find_by_id(user.id).id).to eq(user.id)
|
36
|
+
expect(Spree.user_class.with_deleted.find_by_id(user.id).orders.first).to eq(order)
|
37
37
|
|
38
38
|
expect(Spree::Order.find_by_user_id(user.id)).not_to be_nil
|
39
39
|
expect(Spree::Order.where(user_id: user.id).first).to eq(order)
|
@@ -67,13 +67,13 @@ RSpec.describe Spree::User, type: :model do
|
|
67
67
|
it "is confirmable if the confirmable option is enabled" do
|
68
68
|
set_confirmable_option(true)
|
69
69
|
Spree::UserMailer.stub(:confirmation_instructions).and_return(double(deliver: true))
|
70
|
-
expect(Spree
|
70
|
+
expect(Spree.user_class.devise_modules).to include(:confirmable)
|
71
71
|
set_confirmable_option(false)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "is not confirmable if the confirmable option is disabled" do
|
75
75
|
set_confirmable_option(false)
|
76
|
-
expect(Spree
|
76
|
+
expect(Spree.user_class.devise_modules).to_not include(:confirmable)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/spree_auth_devise.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.name = 'spree_auth_devise'
|
6
|
-
s.version = '4.1.0
|
6
|
+
s.version = '4.1.0'
|
7
7
|
s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.'
|
8
8
|
s.description = s.summary
|
9
9
|
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.add_development_dependency 'rspec-rails', '~> 4.0.0.beta2'
|
46
46
|
s.add_development_dependency 'sass-rails'
|
47
47
|
s.add_development_dependency 'selenium-webdriver'
|
48
|
-
s.add_development_dependency 'shoulda-matchers', '~> 3
|
48
|
+
s.add_development_dependency 'shoulda-matchers', '~> 4.3'
|
49
49
|
s.add_development_dependency 'simplecov', '~> 0.12'
|
50
50
|
s.add_development_dependency 'spree_backend', spree_version
|
51
51
|
s.add_development_dependency 'spree_frontend', spree_version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_auth_devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -330,14 +330,14 @@ dependencies:
|
|
330
330
|
requirements:
|
331
331
|
- - "~>"
|
332
332
|
- !ruby/object:Gem::Version
|
333
|
-
version: '3
|
333
|
+
version: '4.3'
|
334
334
|
type: :development
|
335
335
|
prerelease: false
|
336
336
|
version_requirements: !ruby/object:Gem::Requirement
|
337
337
|
requirements:
|
338
338
|
- - "~>"
|
339
339
|
- !ruby/object:Gem::Version
|
340
|
-
version: '3
|
340
|
+
version: '4.3'
|
341
341
|
- !ruby/object:Gem::Dependency
|
342
342
|
name: simplecov
|
343
343
|
requirement: !ruby/object:Gem::Requirement
|
@@ -561,9 +561,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
561
561
|
version: 2.5.0
|
562
562
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
563
563
|
requirements:
|
564
|
-
- - "
|
564
|
+
- - ">="
|
565
565
|
- !ruby/object:Gem::Version
|
566
|
-
version:
|
566
|
+
version: '0'
|
567
567
|
requirements:
|
568
568
|
- none
|
569
569
|
rubygems_version: 3.0.2
|