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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84725664c8b934aad5a5bf577d7d3d68780a2de90bbe24ab2ad873072bee53c8
4
- data.tar.gz: 6ac102f9f5d9003520ea694db1b396f1c5009561a67f0a5ef986623ba8582c1e
3
+ metadata.gz: 9e0d47cfd1b48b91343c2ba368dc685cf3e8c571a79d7d38c5b49538cf00d16b
4
+ data.tar.gz: ad94efe038f6e2fcc044e7e7943b9b62dc2bd43cb36eb3721d2a81708e596c52
5
5
  SHA512:
6
- metadata.gz: a9fc38b7508fd7b58025858556c94db80d154bce9e838084b4bf1d30cd36703500194046b57ee7ce34b27c49f725845ef86cf13ea342ed0227df3582c0d9ed2a
7
- data.tar.gz: ae8963f1294e759c4eeb4cbeceedc526f99635c5d973e0bcbd641f6142124efc88a8204d51cd555426d6ec8b5d727a52bb376967fbe2eb026282001771084cd9
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
- As part of running the above installation steps, you will be asked to set an admin email/password combination. The default values are `admin@example.com` and `test123`, respectively.
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[:confirmable] = true
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`):
@@ -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[:confirmable]
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[:confirmable]
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"] || "admin@example.com"
11
- password = ENV["ADMIN_PASSWORD"] || "test123"
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)
@@ -0,0 +1,6 @@
1
+ class AddTimezoneToSpreeUsers < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :spree_users, :timezone, :string, if_not_exists: true,
4
+ comment: "User's timezone, e.g., 'Eastern Time (US & Canada)'"
5
+ end
6
+ end
@@ -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.errors.empty?
28
- respond_with resource, location: admin_user_path(resource)
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.errors.empty?
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[:signout_after_password_change]
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
- admin_email = options[:admin_email] || (options[:interactive] && ask("Email:", default: "admin@example.com"))
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Devise.secret_key = '<%= SecureRandom.hex(64) %>'
4
- Devise.email_regexp = Spree::Config[:default_email_regexp]
4
+ Devise.email_regexp = Spree::Config.default_email_regexp
@@ -50,7 +50,7 @@ module SolidusAuthDevise
50
50
  end
51
51
 
52
52
  def registration_required?
53
- Spree::Auth::Config[:registration_step] &&
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[:allow_guest_checkout]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusAuthDevise
4
- VERSION = "2.6.0"
4
+ VERSION = "2.6.1"
5
5
  end
@@ -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[:allow_guest_checkout] %>
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.0
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: 3.6.9
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.