solidus_auth_devise 2.6.0 → 2.6.1
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/Gemfile +3 -0
- data/README.md +12 -2
- data/app/models/spree/user.rb +1 -1
- data/config/routes.rb +1 -1
- data/db/default/users.rb +15 -3
- data/db/migrate/20260422183113_add_timezone_to_spree_users.rb +6 -0
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +3 -2
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +1 -1
- data/lib/controllers/frontend/spree/users_controller.rb +1 -1
- data/lib/generators/solidus/auth/install/install_generator.rb +16 -8
- data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb.erb +1 -1
- data/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb +2 -2
- data/lib/solidus_auth_devise/version.rb +1 -1
- data/lib/views/frontend/spree/checkout/registration.html.erb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e0d47cfd1b48b91343c2ba368dc685cf3e8c571a79d7d38c5b49538cf00d16b
|
|
4
|
+
data.tar.gz: ad94efe038f6e2fcc044e7e7943b9b62dc2bd43cb36eb3721d2a81708e596c52
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e425503e6ee10e0068856686a84fc60ec0ef38280d24e4882364801ff09c7e280604574ab1d3f4417e0ac06c09ae47ff519a4f64ffe8a56fcce806e285abf73
|
|
7
|
+
data.tar.gz: 4124d2869c44f9dd66f9422d4dd31b1d0e68ae663e4f46ebecfc510e106209966d273d66c8d4978d0a2d949a040bffe5d0a1306cb745b079301f7d914130922a
|
data/Gemfile
CHANGED
|
@@ -10,6 +10,9 @@ gem "solidus_backend", github: "solidusio/solidus", branch: branch
|
|
|
10
10
|
rails_requirement_string = ENV.fetch("RAILS_VERSION", "7.0")
|
|
11
11
|
gem "rails", "~> #{rails_requirement_string}"
|
|
12
12
|
|
|
13
|
+
# json 3 is incompatible with Rails < 8.1.
|
|
14
|
+
gem "json", "< 3", require: false
|
|
15
|
+
|
|
13
16
|
# The solidus_frontend gem has been pulled out since v3.2
|
|
14
17
|
if branch >= "v3.2"
|
|
15
18
|
gem "solidus_frontend"
|
data/README.md
CHANGED
|
@@ -27,7 +27,17 @@ bundle exec rake db:seed
|
|
|
27
27
|
|
|
28
28
|
#### Default Username/Password
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
The seed creates an admin user when no admin exists yet. Set the `ADMIN_EMAIL`
|
|
31
|
+
and `ADMIN_PASSWORD` environment variables to choose its credentials:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
ADMIN_EMAIL=you@example.com ADMIN_PASSWORD=... bundle exec rake spree_auth:admin:create
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
In the `development` and `test` environments, the credentials default to
|
|
38
|
+
`admin@example.com` and `test123` when the variables are not set. In every other
|
|
39
|
+
environment (`production`, `staging`, etc.) both variables are required, and the
|
|
40
|
+
seed aborts with an error if either is missing.
|
|
31
41
|
|
|
32
42
|
#### Confirmable
|
|
33
43
|
|
|
@@ -36,7 +46,7 @@ To enable Devise's Confirmable module, which will send the user an email with a
|
|
|
36
46
|
* Add this line to an initializer in your Rails project (typically `config/initializers/spree.rb`):
|
|
37
47
|
|
|
38
48
|
```ruby
|
|
39
|
-
Spree::Auth::Config
|
|
49
|
+
Spree::Auth::Config.confirmable = true
|
|
40
50
|
```
|
|
41
51
|
|
|
42
52
|
* Add a Devise initializer to your Rails project (typically `config/initializers/devise.rb`):
|
data/app/models/spree/user.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Spree
|
|
|
7
7
|
|
|
8
8
|
devise :database_authenticatable, :registerable, :recoverable,
|
|
9
9
|
:rememberable, :trackable, :validatable, :encryptable
|
|
10
|
-
devise :confirmable if Spree::Auth::Config
|
|
10
|
+
devise :confirmable if Spree::Auth::Config.confirmable
|
|
11
11
|
|
|
12
12
|
after_destroy :scramble_email_and_password
|
|
13
13
|
after_discard :scramble_email_and_password
|
data/config/routes.rb
CHANGED
|
@@ -28,7 +28,7 @@ Spree::Core::Engine.routes.draw do
|
|
|
28
28
|
post "/password/recover", to: "user_passwords#create", as: :reset_password
|
|
29
29
|
get "/password/change", to: "user_passwords#edit", as: :edit_password
|
|
30
30
|
put "/password/change", to: "user_passwords#update", as: :update_password
|
|
31
|
-
get "/confirm", to: "user_confirmations#show", as: :confirmation if Spree::Auth::Config
|
|
31
|
+
get "/confirm", to: "user_confirmations#show", as: :confirmation if Spree::Auth::Config.confirmable
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
get "/checkout/registration", to: "checkout#registration", as: :checkout_registration
|
data/db/default/users.rb
CHANGED
|
@@ -7,12 +7,24 @@ if Spree::User.admin.any?
|
|
|
7
7
|
return
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
email = ENV["ADMIN_EMAIL"]
|
|
11
|
-
password = ENV["ADMIN_PASSWORD"]
|
|
10
|
+
email = ENV["ADMIN_EMAIL"]
|
|
11
|
+
password = ENV["ADMIN_PASSWORD"]
|
|
12
|
+
|
|
13
|
+
if Rails.env.development? || Rails.env.test?
|
|
14
|
+
email ||= "admin@example.com"
|
|
15
|
+
password ||= "test123"
|
|
16
|
+
elsif email.blank? || password.blank?
|
|
17
|
+
abort <<~MSG
|
|
18
|
+
Refusing to create an admin user with default credentials in the #{Rails.env} environment.
|
|
19
|
+
Set ADMIN_EMAIL and ADMIN_PASSWORD and run the task again, for example:
|
|
20
|
+
|
|
21
|
+
ADMIN_EMAIL=you@example.com ADMIN_PASSWORD=... bin/rails spree_auth:admin:create
|
|
22
|
+
MSG
|
|
23
|
+
end
|
|
12
24
|
|
|
13
25
|
puts "Creating admin user with:"
|
|
14
26
|
puts " - email: #{email}"
|
|
15
|
-
puts " - password: #{password}"
|
|
27
|
+
puts " - password: #{ENV["ADMIN_PASSWORD"] ? "(from ADMIN_PASSWORD)" : password}"
|
|
16
28
|
puts "(please use the ADMIN_EMAIL and ADMIN_PASSWORD environment variables to control how the default admin user is created)"
|
|
17
29
|
|
|
18
30
|
if Spree::User.find_by(email: email)
|
|
@@ -24,8 +24,9 @@ class Spree::Admin::UserPasswordsController < Devise::PasswordsController
|
|
|
24
24
|
|
|
25
25
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
|
26
26
|
|
|
27
|
-
if resource
|
|
28
|
-
|
|
27
|
+
if successfully_sent?(resource)
|
|
28
|
+
location = (spree_current_user && resource.persisted?) ? admin_user_path(resource) : admin_login_path
|
|
29
|
+
respond_with resource, location: location
|
|
29
30
|
else
|
|
30
31
|
respond_with_navigational(resource) { render :new }
|
|
31
32
|
end
|
|
@@ -20,7 +20,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
|
20
20
|
|
|
21
21
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
|
22
22
|
|
|
23
|
-
if resource
|
|
23
|
+
if successfully_sent?(resource)
|
|
24
24
|
respond_with resource, location: spree.login_path
|
|
25
25
|
else
|
|
26
26
|
respond_with_navigational(resource) { render :new }
|
|
@@ -38,7 +38,7 @@ class Spree::UsersController < Spree::StoreController
|
|
|
38
38
|
|
|
39
39
|
if params[:user][:password].present?
|
|
40
40
|
# this logic needed b/c devise wants to log us out after password changes
|
|
41
|
-
if Spree::Auth::Config
|
|
41
|
+
if Spree::Auth::Config.signout_after_password_change
|
|
42
42
|
redirect_url = spree.login_url
|
|
43
43
|
else
|
|
44
44
|
bypass_sign_in(@user)
|
|
@@ -18,14 +18,7 @@ module Solidus
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def add_migrations
|
|
21
|
-
|
|
22
|
-
admin_password = options[:admin_password] || (options[:interactive] && ask("Password:", default: "test123"))
|
|
23
|
-
|
|
24
|
-
options = []
|
|
25
|
-
options << "ADMIN_EMAIL=#{admin_email}" if admin_email
|
|
26
|
-
options << "ADMIN_PASSWORD=#{admin_password}" if admin_password
|
|
27
|
-
|
|
28
|
-
rake "railties:install:migrations FROM=solidus_auth #{options.shelljoin}"
|
|
21
|
+
rake "railties:install:migrations FROM=solidus_auth"
|
|
29
22
|
end
|
|
30
23
|
|
|
31
24
|
def run_migrations
|
|
@@ -33,11 +26,26 @@ module Solidus
|
|
|
33
26
|
options[:auto_run_migrations] == false || # exclude nil
|
|
34
27
|
options[:interactive] && no?("Would you like to run the migrations now?")
|
|
35
28
|
|
|
29
|
+
@migrations_skipped = true
|
|
36
30
|
say_status :skip, "Skipping rake db:migrate, don't forget to run it!", :yellow
|
|
37
31
|
else
|
|
38
32
|
rake "db:migrate"
|
|
39
33
|
end
|
|
40
34
|
end
|
|
35
|
+
|
|
36
|
+
def create_admin_user
|
|
37
|
+
return if @migrations_skipped
|
|
38
|
+
|
|
39
|
+
admin_email = options[:admin_email] || (options[:interactive] && ask("Email:", default: "admin@example.com"))
|
|
40
|
+
admin_password = options[:admin_password] || (options[:interactive] && ask("Password:", default: "test123"))
|
|
41
|
+
return unless admin_email || admin_password
|
|
42
|
+
|
|
43
|
+
env = []
|
|
44
|
+
env << "ADMIN_EMAIL=#{admin_email.shellescape}" if admin_email
|
|
45
|
+
env << "ADMIN_PASSWORD=#{admin_password.shellescape}" if admin_password
|
|
46
|
+
|
|
47
|
+
rake "spree_auth:admin:create #{env.join(" ")}"
|
|
48
|
+
end
|
|
41
49
|
end
|
|
42
50
|
end
|
|
43
51
|
end
|
|
@@ -50,7 +50,7 @@ module SolidusAuthDevise
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def registration_required?
|
|
53
|
-
Spree::Auth::Config
|
|
53
|
+
Spree::Auth::Config.registration_step &&
|
|
54
54
|
!already_registered?
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ module SolidusAuthDevise
|
|
|
60
60
|
|
|
61
61
|
def guest_authenticated?
|
|
62
62
|
current_order&.email.present? &&
|
|
63
|
-
Spree::Config
|
|
63
|
+
Spree::Config.allow_guest_checkout
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Overrides the equivalent method defined in Spree::Core. This variation of the method will ensure that users
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<div id="account" class="columns alpha eight">
|
|
5
5
|
<%= render template: 'spree/user_sessions/new' %>
|
|
6
6
|
</div>
|
|
7
|
-
<% if Spree::Config
|
|
7
|
+
<% if Spree::Config.allow_guest_checkout %>
|
|
8
8
|
<div id="guest_checkout" data-hook class="columns omega eight">
|
|
9
9
|
<h6><%= t('spree.guest_user_account') %></h6>
|
|
10
10
|
<% if flash[:registration_error] %>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solidus_auth_devise
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.6.
|
|
4
|
+
version: 2.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Solidus Team
|
|
@@ -194,6 +194,7 @@ files:
|
|
|
194
194
|
- db/migrate/20141002154641_add_confirmable_to_users.rb
|
|
195
195
|
- db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb
|
|
196
196
|
- db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb
|
|
197
|
+
- db/migrate/20260422183113_add_timezone_to_spree_users.rb
|
|
197
198
|
- db/seeds.rb
|
|
198
199
|
- lib/controllers/backend/spree/admin/user_passwords_controller.rb
|
|
199
200
|
- lib/controllers/backend/spree/admin/user_sessions_controller.rb
|
|
@@ -264,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
264
265
|
- !ruby/object:Gem::Version
|
|
265
266
|
version: '0'
|
|
266
267
|
requirements: []
|
|
267
|
-
rubygems_version:
|
|
268
|
+
rubygems_version: 4.0.10
|
|
268
269
|
specification_version: 4
|
|
269
270
|
summary: Provides authentication and authorization services for use with Solidus by
|
|
270
271
|
using Devise and CanCan.
|