spree_auth_devise 4.4.1 → 4.5.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +177 -29
- data/Gemfile +12 -4
- data/README.md +6 -13
- data/app/models/spree/user.rb +3 -0
- data/config/initializers/devise.rb +1 -1
- data/config/routes.rb +33 -29
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +6 -5
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +1 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/base_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/orders/customer_details_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/orders_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/auth/admin/resource_controller_decorator.rb +6 -0
- data/lib/controllers/frontend/spree/{checkout_controller_decorator.rb → auth/checkout_controller_decorator.rb} +4 -4
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +2 -2
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +1 -1
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +1 -1
- data/lib/mailers/spree/user_mailer.rb +38 -0
- data/lib/spree/auth/configuration.rb +10 -0
- data/lib/spree/auth/engine.rb +14 -3
- data/lib/spree/auth/version.rb +1 -1
- data/lib/spree/authentication_helpers.rb +6 -6
- data/lib/spree/testing_support/auth_helpers.rb +8 -0
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +18 -15
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +13 -15
- data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +12 -13
- data/lib/views/backend/spree/layouts/login.html.erb +1 -1
- data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.html.erb +0 -0
- data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.text.erb +0 -0
- data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.html.erb +0 -0
- data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.text.erb +0 -0
- data/lib/views/frontend/spree/user_registrations/new.html.erb +1 -1
- data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +2 -2
- data/spec/controllers/spree/products_controller_spec.rb +1 -0
- data/spec/features/account_spec.rb +1 -0
- data/spec/features/admin/password_reset_spec.rb +1 -1
- data/spec/features/admin/sign_in_spec.rb +1 -1
- data/spec/features/admin/sign_out_spec.rb +2 -2
- data/spec/features/checkout_spec.rb +4 -3
- data/spec/features/confirmation_spec.rb +1 -1
- data/spec/features/sign_in_spec.rb +1 -1
- data/spec/mailers/user_mailer_spec.rb +3 -3
- data/spec/models/user_spec.rb +3 -3
- data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +0 -9
- data/spree_auth_devise.gemspec +1 -1
- metadata +18 -18
- data/app/mailers/spree/user_mailer.rb +0 -23
- data/app/models/spree/auth_configuration.rb +0 -8
- data/lib/controllers/backend/spree/admin/resource_controller_decorator.rb +0 -6
data/lib/spree/auth/engine.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'devise'
|
|
2
2
|
require 'devise-encryptable'
|
|
3
3
|
|
|
4
|
+
require_relative 'configuration'
|
|
5
|
+
|
|
4
6
|
module Spree
|
|
5
7
|
module Auth
|
|
6
8
|
class Engine < Rails::Engine
|
|
@@ -8,11 +10,11 @@ module Spree
|
|
|
8
10
|
engine_name 'spree_auth'
|
|
9
11
|
|
|
10
12
|
initializer "spree.auth.environment", before: :load_config_initializers do |_app|
|
|
11
|
-
Spree::Auth::Config = Spree::
|
|
13
|
+
Spree::Auth::Config = Spree::Auth::Configuration.new
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
initializer "spree_auth_devise.set_user_class", after: :load_config_initializers do
|
|
15
|
-
Spree.user_class = 'Spree::User'
|
|
17
|
+
Spree.user_class = 'Spree::User'
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
initializer "spree_auth_devise.check_secret_token" do
|
|
@@ -55,13 +57,17 @@ module Spree
|
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
def self.frontend_available?
|
|
58
|
-
@@frontend_available ||= ::
|
|
60
|
+
@@frontend_available ||= Gem::Specification.find_all_by_name('spree_frontend').any?
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
def self.api_available?
|
|
62
64
|
@@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
|
|
63
65
|
end
|
|
64
66
|
|
|
67
|
+
def self.emails_available?
|
|
68
|
+
@@emails_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Emails::Engine')
|
|
69
|
+
end
|
|
70
|
+
|
|
65
71
|
if backend_available?
|
|
66
72
|
paths["app/controllers"] << "lib/controllers/backend"
|
|
67
73
|
paths["app/views"] << "lib/views/backend"
|
|
@@ -76,6 +82,11 @@ module Spree
|
|
|
76
82
|
paths["app/controllers"] << "lib/controllers/api"
|
|
77
83
|
end
|
|
78
84
|
|
|
85
|
+
if emails_available?
|
|
86
|
+
paths["app/views"] << "lib/views/emails"
|
|
87
|
+
paths["app/mailers"] << "lib/mailers"
|
|
88
|
+
end
|
|
89
|
+
|
|
79
90
|
config.to_prepare &method(:activate).to_proc
|
|
80
91
|
end
|
|
81
92
|
end
|
data/lib/spree/auth/version.rb
CHANGED
|
@@ -11,16 +11,16 @@ module Spree
|
|
|
11
11
|
current_spree_user
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def spree_login_path
|
|
15
|
-
spree.login_path
|
|
14
|
+
def spree_login_path(opts = {})
|
|
15
|
+
spree.login_path(opts)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def spree_signup_path
|
|
19
|
-
spree.signup_path
|
|
18
|
+
def spree_signup_path(opts = {})
|
|
19
|
+
spree.signup_path(opts)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def spree_logout_path
|
|
23
|
-
spree.logout_path
|
|
22
|
+
def spree_logout_path(opts = {})
|
|
23
|
+
spree.logout_path(opts)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -39,6 +39,14 @@ module Spree
|
|
|
39
39
|
click_link Spree.t(:my_account).upcase
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
def wait_for_turbo
|
|
44
|
+
if Spree.version.to_f < 4.5
|
|
45
|
+
expect(page).to have_no_css '.turbolinks-progress-bar'
|
|
46
|
+
else
|
|
47
|
+
expect(page).to have_no_css '.turbo-progress-bar'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
42
50
|
end
|
|
43
51
|
end
|
|
44
52
|
end
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<div id="forgot-password" class="card mt-5 shadow-sm">
|
|
2
|
+
<div class="card-body">
|
|
3
|
+
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
|
|
4
|
+
<h5 class="card-title"><%= Spree.t(:change_my_password) %></h5>
|
|
5
|
+
<%= form_for @spree_user, as: :spree_user, url: spree.admin_update_password_path, method: :put do |f| %>
|
|
6
|
+
<div class="form-group">
|
|
7
|
+
<%= f.label :password, Spree.t(:password) %>
|
|
8
|
+
<%= f.password_field :password, class: 'form-control', required: true %>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="form-group">
|
|
11
|
+
<%= f.label :password_confirmation, Spree.t(:confirm_password) %>
|
|
12
|
+
<%= f.password_field :password_confirmation, class: 'form-control', required: true %>
|
|
13
|
+
</div>
|
|
14
|
+
<%= f.hidden_field :reset_password_token %>
|
|
15
|
+
<%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block' %>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
<div id="forgot-password" class="card mt-5 shadow-sm">
|
|
2
|
+
<div class="card-body">
|
|
3
|
+
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
|
|
2
4
|
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<%= f.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<p>
|
|
14
|
-
<%= f.submit Spree.t(:reset_password), :class => 'button primary' %>
|
|
15
|
-
</p>
|
|
16
|
-
<% end %>
|
|
5
|
+
<h5 class="card-title"><%= Spree.t(:forgot_password) %></h5>
|
|
6
|
+
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
|
7
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_reset_password_path, data: { turbo: false } do |f| %>
|
|
8
|
+
<div class="form-group">
|
|
9
|
+
<%= f.label :email, Spree.t(:email) %>
|
|
10
|
+
<%= f.email_field :email, class: 'form-control', required: true %>
|
|
11
|
+
</div>
|
|
12
|
+
<%= f.submit Spree.t(:reset_password), class: 'btn btn-primary' %>
|
|
13
|
+
<% end %>
|
|
14
|
+
</div>
|
|
17
15
|
</div>
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
<div class="alert alert-danger"><%= flash[:alert] %></div>
|
|
3
|
-
<% end %>
|
|
4
|
-
|
|
5
|
-
<div data-hook="login" class="card border-0">
|
|
1
|
+
<div data-hook="login" class="card mt-5 shadow-sm">
|
|
6
2
|
<div class="card-body">
|
|
3
|
+
<% if flash[:error] %>
|
|
4
|
+
<div class="alert alert-danger"><%= flash[:error] %></div>
|
|
5
|
+
<% end %>
|
|
6
|
+
<h5 class="card-title"><%= Spree.t(:login) %></h5>
|
|
7
|
+
|
|
7
8
|
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
|
|
8
9
|
<div id="password-credentials">
|
|
9
|
-
<div class="form-group
|
|
10
|
-
<%= f.
|
|
11
|
-
<%= f.email_field :email, class: 'form-control', tabindex: 1, placeholder: Spree.t(:email) %>
|
|
10
|
+
<div class="form-group">
|
|
11
|
+
<%= f.email_field :email, class: 'form-control', tabindex: 1, placeholder: Spree.t(:email) %>
|
|
12
12
|
</div>
|
|
13
|
-
<div class="form-group
|
|
14
|
-
<%= f.label :password, Spree.t(:password) %>
|
|
13
|
+
<div class="form-group">
|
|
15
14
|
<%= f.password_field :password, :class => 'form-control', :tabindex => 2, placeholder: Spree.t(:password) %>
|
|
16
15
|
</div>
|
|
17
16
|
</div>
|
|
@@ -21,12 +20,12 @@
|
|
|
21
20
|
<%= f.label :remember_me do %>
|
|
22
21
|
<%= f.check_box :remember_me, :tabindex => 3 %>
|
|
23
22
|
<%= Spree.t(:remember_me) %>
|
|
24
|
-
<% end %>
|
|
23
|
+
<% end %>
|
|
25
24
|
</div>
|
|
26
25
|
<div class="col-lg-6 text-right">
|
|
27
26
|
<%= link_to Spree.t(:forgot_password), spree.admin_recover_password_path %>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
30
29
|
</div>
|
|
31
30
|
<div class="form-group">
|
|
32
31
|
<%= f.submit Spree.t(:login), :class => 'btn btn-primary btn-block', :tabindex => 4 %>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="col-lg-6 offset-lg-3">
|
|
4
4
|
<h3 class="spree-header spree-mb-large spree-mt-large"><%= Spree.t(:new_customer) %></h3>
|
|
5
5
|
<div id="new-customer" data-hook="login">
|
|
6
|
-
<%= form_for resource, as: :spree_user, url: spree.registration_path do |f| %>
|
|
6
|
+
<%= form_for resource, as: :spree_user, url: spree.registration_path, data: { turbo: false } do |f| %>
|
|
7
7
|
<div data-hook="signup_inside_form">
|
|
8
8
|
<%= render partial: 'spree/shared/user_form', locals: { f: f, remember_me_field: true } %>
|
|
9
9
|
<div><%= f.submit Spree.t(:sign_up), class: 'btn btn-primary btn-block spree-btn mb-5' %></div>
|
|
@@ -32,7 +32,7 @@ RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controlle
|
|
|
32
32
|
context 'when updating password with blank password' do
|
|
33
33
|
let(:params) {
|
|
34
34
|
{
|
|
35
|
-
id: user.send_reset_password_instructions(Spree::Store.
|
|
35
|
+
id: user.send_reset_password_instructions(Spree::Store.default),
|
|
36
36
|
user: {
|
|
37
37
|
password: '',
|
|
38
38
|
password_confirmation: ''
|
|
@@ -49,7 +49,7 @@ RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controlle
|
|
|
49
49
|
context 'when updating password with specified password' do
|
|
50
50
|
let(:params) {
|
|
51
51
|
{
|
|
52
|
-
id: user.send_reset_password_instructions(Spree::Store.
|
|
52
|
+
id: user.send_reset_password_instructions(Spree::Store.default),
|
|
53
53
|
user: {
|
|
54
54
|
password: password,
|
|
55
55
|
password_confirmation: password
|
|
@@ -17,6 +17,7 @@ RSpec.describe Spree::ProductsController, type: :controller do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'cannot view non-active products' do
|
|
20
|
+
skip if Spree.version.to_f > 4.0
|
|
20
21
|
allow(user).to receive(:has_spree_role?) { false }
|
|
21
22
|
|
|
22
23
|
# this behaviour was introduced in rails 5.1 & Spree 3.5
|
|
@@ -28,6 +28,7 @@ RSpec.feature 'Accounts', type: :feature do
|
|
|
28
28
|
expect(page).to have_text 'email@person.com'
|
|
29
29
|
|
|
30
30
|
find('a.account-page-user-info-item-title-edit').click
|
|
31
|
+
wait_for_turbo
|
|
31
32
|
|
|
32
33
|
fill_in 'Password', with: 'foobar'
|
|
33
34
|
fill_in 'Password Confirmation', with: 'foobar'
|
|
@@ -7,7 +7,7 @@ RSpec.feature 'Admin - Reset Password', type: :feature do
|
|
|
7
7
|
user = create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret')
|
|
8
8
|
visit spree.admin_login_path
|
|
9
9
|
click_link 'Forgot password?'
|
|
10
|
-
fill_in 'Email', with:
|
|
10
|
+
fill_in 'Email', with: user.email
|
|
11
11
|
click_button 'Reset my password'
|
|
12
12
|
expect(page).to have_text 'You will receive an email with instructions'
|
|
13
13
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
RSpec.feature 'Admin - Sign Out', type: :feature do
|
|
1
|
+
RSpec.feature 'Admin - Sign Out', type: :feature, js: true do
|
|
2
2
|
given!(:user) do
|
|
3
3
|
create :user, email: 'email@person.com'
|
|
4
4
|
end
|
|
@@ -12,7 +12,7 @@ RSpec.feature 'Admin - Sign Out', type: :feature do
|
|
|
12
12
|
click_button Spree.t(:login)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
scenario 'allows a signed in user to logout'
|
|
15
|
+
scenario 'allows a signed in user to logout' do
|
|
16
16
|
log_out
|
|
17
17
|
visit spree.admin_login_path
|
|
18
18
|
expect(page).to have_button Spree.t(:login)
|
|
@@ -73,7 +73,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# Regression test for #890
|
|
76
|
-
|
|
76
|
+
xscenario 'associate an incomplete guest order with user after successful password reset' do
|
|
77
77
|
add_to_cart(mug)
|
|
78
78
|
|
|
79
79
|
visit spree.login_path
|
|
@@ -81,12 +81,12 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
|
81
81
|
fill_in('Email', with: 'email@person.com')
|
|
82
82
|
find('#spree_user_email').set('email@person.com')
|
|
83
83
|
|
|
84
|
-
click_button 'Reset my password'
|
|
84
|
+
expect { click_button 'Reset my password' }.to change { ActionMailer::Base.deliveries.size }.by(1)
|
|
85
85
|
|
|
86
86
|
# Need to do this now because the token stored in the DB is the encrypted version
|
|
87
87
|
# The 'plain-text' version is sent in the email and there's one way to get that!
|
|
88
88
|
reset_password_email = ActionMailer::Base.deliveries.first
|
|
89
|
-
token_url_regex = /^http:\/\/www.example.com\/
|
|
89
|
+
token_url_regex = /^http:\/\/www.example.com\/password\/change\?reset_password_token=(.*)$/
|
|
90
90
|
token = token_url_regex.match(reset_password_email.body.encoded)[1]
|
|
91
91
|
|
|
92
92
|
visit spree.edit_spree_user_password_path(reset_password_token: token.strip).tr("%0D","")
|
|
@@ -103,6 +103,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
|
103
103
|
click_button 'Save and Continue'
|
|
104
104
|
|
|
105
105
|
expect(page).not_to have_text 'Email is invalid'
|
|
106
|
+
ActiveJob::Base.queue_adapter = :test
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
scenario 'allow a user to register during checkout' do
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
RSpec.feature 'Confirmation', type: :feature, confirmable: true do
|
|
4
4
|
before do
|
|
5
|
-
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.
|
|
5
|
+
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.default.id }).and_return(double(deliver: true))
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
background do
|
|
@@ -5,7 +5,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
|
5
5
|
describe '#reset_password_instructions' do
|
|
6
6
|
describe 'message contents' do
|
|
7
7
|
before do
|
|
8
|
-
@message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.
|
|
8
|
+
@message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id })
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
context 'subject includes' do
|
|
@@ -22,7 +22,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
|
22
22
|
|
|
23
23
|
context 'body includes' do
|
|
24
24
|
it 'password reset url' do
|
|
25
|
-
expect(@message.body.encoded).to include "http://#{store.url}/
|
|
25
|
+
expect(@message.body.encoded).to include "http://#{store.url}/password/change"
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -30,7 +30,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
|
30
30
|
describe 'legacy support for User object' do
|
|
31
31
|
it 'sends an email' do
|
|
32
32
|
expect {
|
|
33
|
-
described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.
|
|
33
|
+
described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id }).deliver_now
|
|
34
34
|
}.to change(ActionMailer::Base.deliveries, :size).by(1)
|
|
35
35
|
end
|
|
36
36
|
end
|
data/spec/models/user_spec.rb
CHANGED
|
@@ -9,7 +9,7 @@ RSpec.describe Spree::User, type: :model do
|
|
|
9
9
|
|
|
10
10
|
it 'generates the reset password token' do
|
|
11
11
|
user = build(:user)
|
|
12
|
-
current_store = Spree::Store.
|
|
12
|
+
current_store = Spree::Store.default
|
|
13
13
|
expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, { current_store_id: current_store.id }).and_return(double(deliver: true))
|
|
14
14
|
user.send_reset_password_instructions(current_store)
|
|
15
15
|
expect(user.reset_password_token).not_to be_nil
|
|
@@ -94,7 +94,7 @@ RSpec.describe Spree::User, type: :model do
|
|
|
94
94
|
|
|
95
95
|
describe "confirmable" do
|
|
96
96
|
it "is confirmable if the confirmable option is enabled", confirmable: true do
|
|
97
|
-
Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.
|
|
97
|
+
Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.default.id }).and_return(double(deliver: true))
|
|
98
98
|
expect(Spree.user_class.devise_modules).to include(:confirmable)
|
|
99
99
|
end
|
|
100
100
|
|
|
@@ -112,7 +112,7 @@ RSpec.describe Spree::User, type: :model do
|
|
|
112
112
|
user.email = FFaker::Internet.email
|
|
113
113
|
user.password = user.password_confirmation = 'pass1234'
|
|
114
114
|
user.save
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(
|
|
117
117
|
user, anything, { current_store_id: default_store.id }).and_return(double(deliver: true)
|
|
118
118
|
)
|
|
@@ -35,14 +35,5 @@ describe 'Storefront API v2 Account Confirmation spec', type: :request do
|
|
|
35
35
|
expect(JSON.parse(response.body)['error']).to eq("Confirmation token is invalid")
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
|
-
|
|
39
|
-
context 'blank confirmation_token param' do
|
|
40
|
-
let(:user) { build(:user) }
|
|
41
|
-
let(:confirmation_token) { '' }
|
|
42
|
-
|
|
43
|
-
it 'return 301 status' do
|
|
44
|
-
expect(response.code).to eq('301')
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
38
|
end
|
|
48
39
|
end
|
data/spree_auth_devise.gemspec
CHANGED
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
|
33
33
|
s.add_dependency 'devise', '~> 4.7'
|
|
34
34
|
s.add_dependency 'devise-encryptable', '0.2.0'
|
|
35
35
|
|
|
36
|
-
spree_version = '>= 4.
|
|
36
|
+
spree_version = '>= 4.5.0'
|
|
37
37
|
s.add_dependency 'spree_core', spree_version
|
|
38
38
|
s.add_dependency 'spree_extension'
|
|
39
39
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_auth_devise
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Schofield
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: devise
|
|
@@ -45,14 +45,14 @@ dependencies:
|
|
|
45
45
|
requirements:
|
|
46
46
|
- - ">="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: 4.
|
|
48
|
+
version: 4.5.0
|
|
49
49
|
type: :runtime
|
|
50
50
|
prerelease: false
|
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
|
53
53
|
- - ">="
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: 4.
|
|
55
|
+
version: 4.5.0
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
57
|
name: spree_extension
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,13 +102,7 @@ files:
|
|
|
102
102
|
- app/controllers/metal_decorator.rb
|
|
103
103
|
- app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb
|
|
104
104
|
- app/controllers/spree/api/v2/storefront/passwords_controller.rb
|
|
105
|
-
- app/mailers/spree/user_mailer.rb
|
|
106
|
-
- app/models/spree/auth_configuration.rb
|
|
107
105
|
- app/models/spree/user.rb
|
|
108
|
-
- app/views/spree/user_mailer/confirmation_instructions.html.erb
|
|
109
|
-
- app/views/spree/user_mailer/confirmation_instructions.text.erb
|
|
110
|
-
- app/views/spree/user_mailer/reset_password_instructions.html.erb
|
|
111
|
-
- app/views/spree/user_mailer/reset_password_instructions.text.erb
|
|
112
106
|
- bin/rails
|
|
113
107
|
- config.ru
|
|
114
108
|
- config/initializers/devise.rb
|
|
@@ -136,13 +130,13 @@ files:
|
|
|
136
130
|
- db/migrate/20150416152553_add_missing_indices_on_user.rb
|
|
137
131
|
- db/migrate/20210728103922_change_type_of_ship_address_id_and_bill_address_id_for_spree_users.rb
|
|
138
132
|
- db/seeds.rb
|
|
139
|
-
- lib/controllers/backend/spree/admin/base_controller_decorator.rb
|
|
140
|
-
- lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb
|
|
141
|
-
- lib/controllers/backend/spree/admin/orders_controller_decorator.rb
|
|
142
|
-
- lib/controllers/backend/spree/admin/resource_controller_decorator.rb
|
|
143
133
|
- lib/controllers/backend/spree/admin/user_passwords_controller.rb
|
|
144
134
|
- lib/controllers/backend/spree/admin/user_sessions_controller.rb
|
|
145
|
-
- lib/controllers/
|
|
135
|
+
- lib/controllers/backend/spree/auth/admin/base_controller_decorator.rb
|
|
136
|
+
- lib/controllers/backend/spree/auth/admin/orders/customer_details_controller_decorator.rb
|
|
137
|
+
- lib/controllers/backend/spree/auth/admin/orders_controller_decorator.rb
|
|
138
|
+
- lib/controllers/backend/spree/auth/admin/resource_controller_decorator.rb
|
|
139
|
+
- lib/controllers/frontend/spree/auth/checkout_controller_decorator.rb
|
|
146
140
|
- lib/controllers/frontend/spree/user_confirmations_controller.rb
|
|
147
141
|
- lib/controllers/frontend/spree/user_passwords_controller.rb
|
|
148
142
|
- lib/controllers/frontend/spree/user_registrations_controller.rb
|
|
@@ -150,7 +144,9 @@ files:
|
|
|
150
144
|
- lib/controllers/frontend/spree/users_controller.rb
|
|
151
145
|
- lib/generators/spree/auth/install/install_generator.rb
|
|
152
146
|
- lib/generators/spree/auth/install/templates/config/initializers/devise.rb
|
|
147
|
+
- lib/mailers/spree/user_mailer.rb
|
|
153
148
|
- lib/spree/auth.rb
|
|
149
|
+
- lib/spree/auth/configuration.rb
|
|
154
150
|
- lib/spree/auth/devise.rb
|
|
155
151
|
- lib/spree/auth/engine.rb
|
|
156
152
|
- lib/spree/auth/version.rb
|
|
@@ -165,6 +161,10 @@ files:
|
|
|
165
161
|
- lib/views/backend/spree/admin/user_sessions/new.html.erb
|
|
166
162
|
- lib/views/backend/spree/layouts/admin/_login_nav.html.erb
|
|
167
163
|
- lib/views/backend/spree/layouts/login.html.erb
|
|
164
|
+
- lib/views/emails/spree/user_mailer/confirmation_instructions.html.erb
|
|
165
|
+
- lib/views/emails/spree/user_mailer/confirmation_instructions.text.erb
|
|
166
|
+
- lib/views/emails/spree/user_mailer/reset_password_instructions.html.erb
|
|
167
|
+
- lib/views/emails/spree/user_mailer/reset_password_instructions.text.erb
|
|
168
168
|
- lib/views/frontend/spree/shared/_flashes.html.erb
|
|
169
169
|
- lib/views/frontend/spree/shared/_login_bar.html.erb
|
|
170
170
|
- lib/views/frontend/spree/user_passwords/edit.html.erb
|
|
@@ -213,9 +213,9 @@ licenses:
|
|
|
213
213
|
- BSD-3-Clause
|
|
214
214
|
metadata:
|
|
215
215
|
bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
|
|
216
|
-
changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.
|
|
216
|
+
changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.5.0
|
|
217
217
|
documentation_uri: https://guides.spreecommerce.org/
|
|
218
|
-
source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.
|
|
218
|
+
source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.5.0
|
|
219
219
|
post_install_message:
|
|
220
220
|
rdoc_options: []
|
|
221
221
|
require_paths:
|
|
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
232
232
|
version: '0'
|
|
233
233
|
requirements:
|
|
234
234
|
- none
|
|
235
|
-
rubygems_version: 3.
|
|
235
|
+
rubygems_version: 3.0.9
|
|
236
236
|
signing_key:
|
|
237
237
|
specification_version: 4
|
|
238
238
|
summary: Provides authentication and authorization services for use with Spree by
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
class UserMailer < defined?(Spree::BaseMailer) ? Spree::BaseMailer : ActionMailer::Base
|
|
3
|
-
def reset_password_instructions(user, token, *_args)
|
|
4
|
-
current_store_id = _args.inject(:merge)[:current_store_id]
|
|
5
|
-
@current_store = Spree::Store.find(current_store_id) || Spree::Store.current
|
|
6
|
-
@locale = @current_store.has_attribute?(:default_locale) ? @current_store.default_locale : I18n.default_locale
|
|
7
|
-
I18n.locale = @locale if @locale.present?
|
|
8
|
-
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @current_store.url)
|
|
9
|
-
@user = user
|
|
10
|
-
|
|
11
|
-
mail to: user.email, from: @current_store.mail_from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]), store_url: @current_store.url
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def confirmation_instructions(user, token, _opts = {})
|
|
15
|
-
current_store_id = _opts[:current_store_id]
|
|
16
|
-
@current_store = Spree::Store.find(current_store_id) || Spree::Store.current
|
|
17
|
-
@confirmation_url = spree.confirmation_url(confirmation_token: token, host: Spree::Store.current.url)
|
|
18
|
-
@email = user.email
|
|
19
|
-
|
|
20
|
-
mail to: user.email, from: @current_store.mail_from_address, subject: @current_store.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]), store_url: @current_store.url
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
class AuthConfiguration < Preferences::Configuration
|
|
3
|
-
preference :registration_step, :boolean, default: true
|
|
4
|
-
preference :signout_after_password_change, :boolean, default: true
|
|
5
|
-
preference :confirmable, :boolean, default: false
|
|
6
|
-
preference :validatable, :boolean, default: true
|
|
7
|
-
end
|
|
8
|
-
end
|