solidus_auth_devise 2.0.0 → 2.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 +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +12 -8
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +284 -145
- data/Gemfile +22 -14
- data/{LICENSE.md → LICENSE} +2 -2
- data/README.md +50 -3
- data/Rakefile +2 -0
- data/app/mailers/spree/user_mailer.rb +4 -2
- data/app/models/spree/auth_configuration.rb +2 -0
- data/app/models/spree/user.rb +30 -20
- data/app/overrides/spree/admin/users/edit/_add_reset_password_form.html.erb.deface +20 -0
- data/bin/console +17 -0
- data/bin/rails +12 -4
- data/bin/setup +8 -0
- data/config/initializers/devise.rb +11 -3
- data/config/initializers/warden.rb +4 -2
- data/config/locales/en.yml +4 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/it.yml +4 -4
- data/config/routes.rb +16 -15
- data/db/default/users.rb +10 -8
- data/db/migrate/20101026184949_create_users.rb +9 -7
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +3 -1
- data/db/migrate/20101214150824_convert_user_remember_field.rb +2 -0
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -0
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +4 -2
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +2 -0
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +2 -0
- data/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb +34 -0
- data/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb +7 -0
- data/db/seeds.rb +2 -0
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +7 -4
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +12 -10
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +2 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +4 -1
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +4 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +4 -2
- data/lib/controllers/frontend/spree/users_controller.rb +20 -15
- data/lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb +20 -0
- data/lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb +22 -0
- data/lib/{controllers/frontend → decorators/frontend/controllers}/spree/checkout_controller_decorator.rb +29 -19
- data/lib/generators/solidus/auth/install/install_generator.rb +15 -3
- data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +3 -1
- data/lib/solidus/auth.rb +2 -0
- data/lib/solidus_auth_devise.rb +13 -5
- data/lib/spree/auth/devise.rb +2 -7
- data/lib/spree/auth/engine.rb +51 -38
- data/lib/spree/auth/version.rb +7 -0
- data/lib/spree/authentication_helpers.rb +5 -11
- data/lib/tasks/auth.rake +3 -1
- data/lib/views/backend/spree/admin/shared/_navigation_footer.html.erb +13 -6
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +4 -4
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +6 -8
- 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 +9 -9
- data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +4 -4
- data/lib/views/frontend/spree/checkout/registration.html.erb +4 -4
- data/lib/views/frontend/spree/shared/_login.html.erb +4 -4
- data/lib/views/frontend/spree/shared/_login_bar.html.erb +2 -6
- data/lib/views/frontend/spree/shared/_login_bar_items.html.erb +6 -0
- data/lib/views/frontend/spree/shared/_user_form.html.erb +3 -3
- data/lib/views/frontend/spree/user_passwords/edit.html.erb +4 -4
- data/lib/views/frontend/spree/user_passwords/new.html.erb +5 -7
- data/lib/views/frontend/spree/user_registrations/new.html.erb +3 -3
- data/lib/views/frontend/spree/user_sessions/authorization_failure.html.erb +1 -1
- data/lib/views/frontend/spree/user_sessions/new.html.erb +2 -2
- data/lib/views/frontend/spree/users/edit.html.erb +2 -2
- data/lib/views/frontend/spree/users/show.html.erb +12 -12
- data/solidus_auth_devise.gemspec +38 -31
- data/spec/controllers/spree/admin/base_controller_spec.rb +53 -0
- data/spec/controllers/spree/admin/user_passwords_controller_spec.rb +14 -0
- data/spec/controllers/spree/base_controller_spec.rb +53 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +6 -10
- data/spec/controllers/spree/products_controller_spec.rb +6 -3
- data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -3
- data/spec/controllers/spree/user_registrations_controller_spec.rb +3 -2
- data/spec/controllers/spree/user_sessions_controller_spec.rb +14 -0
- data/spec/controllers/spree/users_controller_spec.rb +26 -8
- data/spec/factories/confirmed_user.rb +7 -5
- data/spec/features/account_spec.rb +4 -3
- data/spec/features/admin/password_reset_spec.rb +66 -10
- data/spec/features/admin/products_spec.rb +2 -1
- data/spec/features/admin/sign_in_spec.rb +2 -1
- data/spec/features/admin/sign_out_spec.rb +2 -1
- data/spec/features/admin_permissions_spec.rb +2 -1
- data/spec/features/change_email_spec.rb +3 -2
- data/spec/features/checkout_spec.rb +14 -37
- data/spec/features/confirmation_spec.rb +6 -10
- data/spec/features/order_spec.rb +2 -1
- data/spec/features/password_reset_spec.rb +23 -10
- data/spec/features/sign_in_spec.rb +2 -1
- data/spec/features/sign_out_spec.rb +4 -3
- data/spec/features/sign_up_spec.rb +2 -1
- data/spec/mailers/user_mailer_spec.rb +2 -1
- data/spec/models/order_spec.rb +2 -1
- data/spec/models/user_spec.rb +57 -38
- data/spec/spec_helper.rb +13 -9
- data/spec/support/ability.rb +3 -1
- data/spec/support/authentication_helpers.rb +2 -0
- data/spec/support/confirm_helpers.rb +23 -10
- data/spec/support/email.rb +2 -0
- data/spec/support/features/fill_addresses_fields.rb +29 -0
- data/spec/support/preferences.rb +10 -2
- data/spec/support/spree.rb +2 -0
- metadata +327 -243
- data/.travis.yml +0 -22
- data/app/overrides/auth_admin_login_navigation_bar.rb +0 -11
- data/app/overrides/auth_shared_login_bar.rb +0 -10
- data/circle.yml +0 -6
- data/lib/assets/javascripts/spree/backend/solidus_auth.js +0 -1
- data/lib/assets/javascripts/spree/frontend/solidus_auth.js +0 -1
- data/lib/assets/stylesheets/spree/backend/solidus_auth.css +0 -3
- data/lib/assets/stylesheets/spree/frontend/solidus_auth.css +0 -3
- data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +0 -11
- data/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +0 -20
- data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +0 -15
- data/spec/features/admin/orders_spec.rb +0 -30
data/Gemfile
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
gem "rails-controller-testing"
|
|
9
|
-
else
|
|
10
|
-
gem "rails_test_params_backport"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
6
|
+
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
|
7
|
+
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
|
10
|
+
# otherwise it takes forever to resolve them.
|
|
11
|
+
# See https://github.com/bundler/bundler/issues/6677
|
|
12
|
+
gem 'rails', '>0.a'
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
case ENV['DB']
|
|
15
|
+
when 'mysql'
|
|
16
|
+
gem 'mysql2'
|
|
17
|
+
when 'postgresql'
|
|
18
|
+
gem 'pg'
|
|
19
|
+
else
|
|
20
|
+
gem 'sqlite3'
|
|
19
21
|
end
|
|
20
22
|
|
|
23
|
+
gem 'rails-controller-testing', group: :test
|
|
24
|
+
|
|
21
25
|
gemspec
|
|
26
|
+
|
|
27
|
+
# Use a local Gemfile to include development dependencies that might not be
|
|
28
|
+
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
|
|
29
|
+
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
|
data/{LICENSE.md → LICENSE}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2020 Solidus Team
|
|
2
2
|
All rights reserved.
|
|
3
3
|
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification,
|
|
@@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
|
|
|
9
9
|
* Redistributions in binary form must reproduce the above copyright notice,
|
|
10
10
|
this list of conditions and the following disclaimer in the documentation
|
|
11
11
|
and/or other materials provided with the distribution.
|
|
12
|
-
* Neither the name
|
|
12
|
+
* Neither the name Solidus nor the names of its contributors may be used to
|
|
13
13
|
endorse or promote products derived from this software without specific
|
|
14
14
|
prior written permission.
|
|
15
15
|
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Solidus Auth (Devise)
|
|
2
2
|
=====================
|
|
3
3
|
|
|
4
|
+
[](https://circleci.com/gh/solidusio/solidus_auth_devise)
|
|
5
|
+
|
|
4
6
|
Provides authentication services for Solidus, using the Devise gem.
|
|
5
7
|
|
|
6
8
|
Installation
|
|
@@ -10,6 +12,9 @@ Just add this line to your `Gemfile`:
|
|
|
10
12
|
|
|
11
13
|
```ruby
|
|
12
14
|
gem "solidus_auth_devise"
|
|
15
|
+
|
|
16
|
+
# For Solidus versions < 2.5
|
|
17
|
+
# gem 'deface'
|
|
13
18
|
```
|
|
14
19
|
|
|
15
20
|
Then, run `bundle install`.
|
|
@@ -43,9 +48,6 @@ Devise.setup do |config|
|
|
|
43
48
|
# Required so users don't lose their carts when they need to confirm.
|
|
44
49
|
config.allow_unconfirmed_access_for = 1.days
|
|
45
50
|
|
|
46
|
-
# Fixes the bug where Confirmation errors result in a broken page.
|
|
47
|
-
config.router_name = :spree
|
|
48
|
-
|
|
49
51
|
# Add any other devise configurations here, as they will override the defaults provided by solidus_auth_devise.
|
|
50
52
|
end
|
|
51
53
|
```
|
|
@@ -93,3 +95,48 @@ Run the following to automatically build a dummy app if necessary and run the te
|
|
|
93
95
|
```shell
|
|
94
96
|
bundle exec rake
|
|
95
97
|
```
|
|
98
|
+
|
|
99
|
+
## Releasing a new version
|
|
100
|
+
|
|
101
|
+
#### 1. Bump gem version and push to RubyGems
|
|
102
|
+
|
|
103
|
+
We use [gem-release](https://github.com/svenfuchs/gem-release) to release this
|
|
104
|
+
extension with ease.
|
|
105
|
+
|
|
106
|
+
Supposing you are on the master branch and you are working on a fork of this
|
|
107
|
+
extension, `upstream` is the main remote and you have write access to it, you
|
|
108
|
+
can simply run:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
gem bump --version minor --tag --release
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This command will:
|
|
115
|
+
|
|
116
|
+
- bump the gem version to the next minor (changing the `version.rb` file)
|
|
117
|
+
- commit the change and push it to upstream master
|
|
118
|
+
- create a git tag
|
|
119
|
+
- push the tag to the upstream remote
|
|
120
|
+
- release the new version on RubyGems
|
|
121
|
+
|
|
122
|
+
Or you can run these commands individually:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
gem bump --version minor
|
|
126
|
+
gem tag
|
|
127
|
+
gem release
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### 2. Publish the updated CHANGELOG
|
|
131
|
+
|
|
132
|
+
After the release is done we can generate the updated CHANGELOG
|
|
133
|
+
using
|
|
134
|
+
[github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator)
|
|
135
|
+
by running the following command:
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
bundle exec github_changelog_generator solidusio/solidus_auth_devise --token YOUR_GITHUB_TOKEN
|
|
140
|
+
git commit -am 'Update CHANGELOG'
|
|
141
|
+
git push upstream master
|
|
142
|
+
```
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Spree
|
|
2
4
|
class UserMailer < BaseMailer
|
|
3
|
-
def reset_password_instructions(user, token, *
|
|
5
|
+
def reset_password_instructions(user, token, *_args)
|
|
4
6
|
@store = Spree::Store.default
|
|
5
7
|
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @store.url)
|
|
6
8
|
mail to: user.email, from: from_address(@store), subject: "#{@store.name} #{I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])}"
|
|
7
9
|
end
|
|
8
10
|
|
|
9
|
-
def confirmation_instructions(user, token,
|
|
11
|
+
def confirmation_instructions(user, token, _opts = {})
|
|
10
12
|
@store = Spree::Store.default
|
|
11
13
|
@confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: @store.url)
|
|
12
14
|
mail to: user.email, from: from_address(@store), subject: "#{@store.name} #{I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions])}"
|
data/app/models/spree/user.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Spree
|
|
2
4
|
class User < Spree::Base
|
|
3
5
|
include UserMethods
|
|
@@ -8,14 +10,15 @@ module Spree
|
|
|
8
10
|
|
|
9
11
|
acts_as_paranoid
|
|
10
12
|
after_destroy :scramble_email_and_password
|
|
11
|
-
before_update { generate_spree_api_key if encrypted_password_changed? && spree_api_key.present? }
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
def password=(new_password)
|
|
15
|
+
generate_spree_api_key if new_password.present? && spree_api_key.present?
|
|
16
|
+
super
|
|
17
|
+
end
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
roles_table_name = Role.table_name
|
|
19
|
+
before_validation :set_login
|
|
17
20
|
|
|
18
|
-
scope :admin, -> { includes(:spree_roles).where("#{
|
|
21
|
+
scope :admin, -> { includes(:spree_roles).where("#{Role.table_name}.name" => "admin") }
|
|
19
22
|
|
|
20
23
|
def self.admin_created?
|
|
21
24
|
User.admin.count > 0
|
|
@@ -25,24 +28,31 @@ module Spree
|
|
|
25
28
|
has_spree_role?('admin')
|
|
26
29
|
end
|
|
27
30
|
|
|
31
|
+
def confirmed?
|
|
32
|
+
!!confirmed_at
|
|
33
|
+
end
|
|
34
|
+
|
|
28
35
|
protected
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
|
|
37
|
+
def password_required?
|
|
38
|
+
!persisted? || password.present? || password_confirmation.present?
|
|
39
|
+
end
|
|
32
40
|
|
|
33
41
|
private
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
def set_login
|
|
44
|
+
# for now force login to be same as email, eventually we will make this configurable, etc.
|
|
45
|
+
self.login ||= email if email
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def scramble_email_and_password
|
|
49
|
+
return true if destroyed?
|
|
50
|
+
|
|
51
|
+
self.email = SecureRandom.uuid + "@example.net"
|
|
52
|
+
self.login = email
|
|
53
|
+
self.password = SecureRandom.hex(8)
|
|
54
|
+
self.password_confirmation = password
|
|
55
|
+
save
|
|
56
|
+
end
|
|
47
57
|
end
|
|
48
58
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
insert_before "fieldset#admin_user_edit_api_key"
|
|
3
|
+
original "904c52ff702412d1dc8d55ff44d87d7f581f6675"
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<% if @user != try_spree_current_user %>
|
|
7
|
+
<fieldset class="no-border-bottom" data-hook="admin_user_reset_password">
|
|
8
|
+
<legend><%= t(:'spree.forgot_password') %></legend>
|
|
9
|
+
|
|
10
|
+
<%= form_for [:admin, @user], as: :spree_user, url: admin_reset_password_path, method: :post do |f| %>
|
|
11
|
+
<%= f.hidden_field :email, value: @user.email %>
|
|
12
|
+
|
|
13
|
+
<% if can?(:update, @user) %>
|
|
14
|
+
<div class="align-center">
|
|
15
|
+
<%= f.submit Spree.user_class.human_attribute_name(:reset_password), class: "button primary" %>
|
|
16
|
+
</div>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</fieldset>
|
|
20
|
+
<% end %>
|
data/bin/console
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
|
|
5
|
+
require "bundler/setup"
|
|
6
|
+
require "solidus_auth_devise"
|
|
7
|
+
|
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
10
|
+
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
|
|
11
|
+
|
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
13
|
+
# require "pry"
|
|
14
|
+
# Pry.start
|
|
15
|
+
|
|
16
|
+
require "irb"
|
|
17
|
+
IRB.start(__FILE__)
|
data/bin/rails
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
ENGINE_PATH = File.expand_path('../../lib/spree/auth/engine', __FILE__)
|
|
3
|
+
# frozen_string_literal: true
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
app_root = 'spec/dummy'
|
|
6
|
+
|
|
7
|
+
unless File.exist? "#{app_root}/bin/rails"
|
|
8
|
+
system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
|
|
9
|
+
warn "Automatic creation of the dummy app failed"
|
|
10
|
+
exit 1
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Dir.chdir app_root
|
|
15
|
+
exec 'bin/rails', *ARGV
|
data/bin/setup
ADDED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
|
2
4
|
# four configuration values can also be set straight in your models.
|
|
3
5
|
Devise.setup do |config|
|
|
@@ -29,7 +31,7 @@ Devise.setup do |config|
|
|
|
29
31
|
config.http_authenticatable = true
|
|
30
32
|
|
|
31
33
|
# Set this to true to use Basic Auth for AJAX requests. True by default.
|
|
32
|
-
#config.http_authenticatable_on_xhr = false
|
|
34
|
+
# config.http_authenticatable_on_xhr = false
|
|
33
35
|
|
|
34
36
|
# The realm used in Http Basic Authentication
|
|
35
37
|
config.http_authentication_realm = 'Spree Application'
|
|
@@ -41,7 +43,11 @@ Devise.setup do |config|
|
|
|
41
43
|
config.encryptor = 'authlogic_sha512'
|
|
42
44
|
|
|
43
45
|
# Setup a pepper to generate the encrypted password.
|
|
44
|
-
config.pepper = Rails.configuration.secret_token
|
|
46
|
+
config.pepper = if Rails.configuration.respond_to?(:secret_token) && Rails.configuration.secret_token.present?
|
|
47
|
+
Rails.configuration.secret_token
|
|
48
|
+
else
|
|
49
|
+
Rails.configuration.secret_key_base
|
|
50
|
+
end
|
|
45
51
|
|
|
46
52
|
# ==> Configuration for :confirmable
|
|
47
53
|
# The time you want to give your user to confirm his account. During this time
|
|
@@ -114,6 +120,9 @@ Devise.setup do |config|
|
|
|
114
120
|
# should add them to the navigational formats lists. Default is [:html]
|
|
115
121
|
config.navigational_formats = [:html, :json, :xml]
|
|
116
122
|
|
|
123
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
|
124
|
+
config.sign_out_via = :delete
|
|
125
|
+
|
|
117
126
|
# ==> Warden configuration
|
|
118
127
|
# If you want to use other strategies, that are not (yet) supported by Devise,
|
|
119
128
|
# you can configure them inside the config.warden block. The example below
|
|
@@ -132,7 +141,6 @@ Devise.setup do |config|
|
|
|
132
141
|
# Don't put a too small interval or your users won't have the time to
|
|
133
142
|
# change their passwords.
|
|
134
143
|
config.reset_password_within = 6.hours
|
|
135
|
-
config.sign_out_via = :get
|
|
136
144
|
|
|
137
145
|
config.case_insensitive_keys = [:email]
|
|
138
146
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Merges users orders to their account after sign in and sign up.
|
|
2
|
-
Warden::Manager.after_set_user except: :fetch do |user, auth,
|
|
4
|
+
Warden::Manager.after_set_user except: :fetch do |user, auth, _opts|
|
|
3
5
|
if auth.cookies.signed[:guest_token].present?
|
|
4
6
|
if user.is_a?(Spree::User)
|
|
5
7
|
Spree::Order.incomplete.where(guest_token: auth.cookies.signed[:guest_token], user_id: nil).each do |order|
|
|
@@ -9,6 +11,6 @@ Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
|
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
|
|
12
|
-
Warden::Manager.before_logout do |
|
|
14
|
+
Warden::Manager.before_logout do |_user, auth, _opts|
|
|
13
15
|
auth.cookies.delete :guest_token
|
|
14
16
|
end
|
data/config/locales/en.yml
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
en:
|
|
3
3
|
spree:
|
|
4
4
|
admin_login: Admin Login
|
|
5
|
+
change_my_password: Change my password
|
|
5
6
|
devise:
|
|
6
7
|
confirmations:
|
|
7
8
|
confirmed: Your account was successfully confirmed. You are now signed in.
|
|
@@ -32,8 +33,10 @@ en:
|
|
|
32
33
|
spree_user:
|
|
33
34
|
cannot_be_blank: Your password cannot be blank.
|
|
34
35
|
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
|
35
|
-
send_instructions:
|
|
36
|
+
send_instructions: If an account with that email address exists, you will receive an email with instructions about how to reset your password in a few minutes.
|
|
36
37
|
updated: Your password was changed successfully. You are now signed in.
|
|
38
|
+
passwords:
|
|
39
|
+
send_instructions: If an account with that email address exists, you will receive an email with instructions about how to reset your password in a few minutes.
|
|
37
40
|
user_registrations:
|
|
38
41
|
destroyed: Bye! Your account was successfully cancelled. We hope to see you again soon.
|
|
39
42
|
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
|
data/config/locales/fr.yml
CHANGED
|
@@ -46,5 +46,5 @@ fr:
|
|
|
46
46
|
not_found: "n'a pas été trouvé"
|
|
47
47
|
not_locked: "n'a pas été bloqué"
|
|
48
48
|
not_saved:
|
|
49
|
-
one: "1 erreur interdit cette %{
|
|
49
|
+
one: "1 erreur interdit cette %{resource} d'être enregistrée :"
|
|
50
50
|
other: "%{count} erreurs interdisent cette %{resource} d'être enregistrée :"
|
data/config/locales/it.yml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
---
|
|
1
2
|
it:
|
|
2
3
|
spree:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
users: Utenti
|
|
4
|
+
admin_login: Login Amministrazione
|
|
5
|
+
change_my_password: Cambia la password
|
|
6
6
|
devise:
|
|
7
7
|
confirmations:
|
|
8
8
|
confirmed: Il tuo account è stato correttamente confermato. Ora sei collegato.
|
|
@@ -65,9 +65,9 @@ it:
|
|
|
65
65
|
signed_out: Uscito correttamente.
|
|
66
66
|
errors:
|
|
67
67
|
messages:
|
|
68
|
-
email_is_invalid: L'indirizzo email non può essere vuoto
|
|
69
68
|
already_confirmed: è stato già confermato
|
|
70
69
|
confirmation_period_expired: deve essere confermato entro %{period}, richiedi una nuova conferma
|
|
70
|
+
email_is_invalid: L'indirizzo email non può essere vuoto
|
|
71
71
|
expired: è scaduto, si prega di richiederne uno nuovo
|
|
72
72
|
not_found: non trovato
|
|
73
73
|
not_locked: non era bloccato
|
data/config/routes.rb
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
if (
|
|
3
|
-
SolidusSupport.frontend_available? &&
|
|
4
|
-
Spree::Auth::Config.draw_frontend_routes
|
|
5
|
-
)
|
|
1
|
+
# frozen_string_literal: true
|
|
6
2
|
|
|
3
|
+
Spree::Core::Engine.routes.draw do
|
|
4
|
+
if SolidusSupport.frontend_available? && Spree::Auth::Config.draw_frontend_routes
|
|
7
5
|
devise_for(:spree_user, {
|
|
8
6
|
class_name: 'Spree::User',
|
|
9
7
|
controllers: {
|
|
@@ -14,7 +12,8 @@ Spree::Core::Engine.routes.draw do
|
|
|
14
12
|
},
|
|
15
13
|
skip: [:unlocks, :omniauth_callbacks],
|
|
16
14
|
path_names: { sign_out: 'logout' },
|
|
17
|
-
path_prefix: :user
|
|
15
|
+
path_prefix: :user,
|
|
16
|
+
router_name: :spree
|
|
18
17
|
})
|
|
19
18
|
|
|
20
19
|
resources :users, only: [:edit, :update]
|
|
@@ -38,28 +37,30 @@ Spree::Core::Engine.routes.draw do
|
|
|
38
37
|
resource :account, controller: 'users'
|
|
39
38
|
end
|
|
40
39
|
|
|
41
|
-
if
|
|
42
|
-
SolidusSupport.backend_available? &&
|
|
43
|
-
Spree::Auth::Config.draw_backend_routes
|
|
44
|
-
)
|
|
45
|
-
|
|
40
|
+
if SolidusSupport.backend_available? && Spree::Auth::Config.draw_backend_routes
|
|
46
41
|
namespace :admin do
|
|
47
42
|
devise_for(:spree_user, {
|
|
48
43
|
class_name: 'Spree::User',
|
|
44
|
+
singular: :spree_user,
|
|
45
|
+
skip: :all,
|
|
46
|
+
path_names: { sign_out: 'logout' },
|
|
49
47
|
controllers: {
|
|
50
48
|
sessions: 'spree/admin/user_sessions',
|
|
51
49
|
passwords: 'spree/admin/user_passwords'
|
|
52
50
|
},
|
|
53
|
-
|
|
54
|
-
path_names: { sign_out: 'logout' },
|
|
55
|
-
path_prefix: :user
|
|
51
|
+
router_name: :spree
|
|
56
52
|
})
|
|
57
53
|
|
|
58
54
|
devise_scope :spree_user do
|
|
59
55
|
get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
|
|
60
56
|
get '/login', to: 'user_sessions#new', as: :login
|
|
61
57
|
post '/login', to: 'user_sessions#create', as: :create_new_session
|
|
62
|
-
|
|
58
|
+
match '/logout', to: 'user_sessions#destroy', as: :logout, via: Devise.sign_out_via
|
|
59
|
+
|
|
60
|
+
get '/password/recover', to: 'user_passwords#new', as: :recover_password
|
|
61
|
+
post '/password/recover', to: 'user_passwords#create', as: :reset_password
|
|
62
|
+
get '/password/change', to: 'user_passwords#edit', as: :edit_password
|
|
63
|
+
put '/password/change', to: 'user_passwords#update', as: :update_password
|
|
63
64
|
end
|
|
64
65
|
end
|
|
65
66
|
end
|