spree_auth_devise 4.0.0.rc2 → 4.1.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/.circleci/config.yml +41 -0
- data/.gitignore +1 -0
- data/.travis.yml +3 -21
- data/Appraisals +3 -19
- data/Gemfile +2 -2
- data/README.md +3 -12
- data/app/controllers/spree/user_confirmations_controller.rb +24 -0
- data/app/controllers/spree/user_passwords_controller.rb +2 -0
- data/app/controllers/spree/user_registrations_controller.rb +27 -1
- data/app/controllers/spree/user_sessions_controller.rb +23 -1
- data/app/views/spree/user_passwords/edit.html.erb +20 -17
- data/app/views/spree/user_passwords/new.html.erb +17 -15
- data/app/views/spree/user_registrations/new.html.erb +12 -17
- data/app/views/spree/user_sessions/new.html.erb +11 -12
- data/config/locales/en.yml +3 -1
- data/config/routes.rb +2 -3
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
- data/gemfiles/{spree_3_5.gemfile → spree_4_1.gemfile} +1 -1
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +2 -2
- data/lib/controllers/frontend/spree/users_controller.rb +11 -6
- data/lib/generators/spree/auth/install/install_generator.rb +0 -4
- data/lib/spree/testing_support/auth_helpers.rb +36 -0
- data/lib/spree/testing_support/checkout_helpers.rb +24 -0
- 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/admin/orders_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +1 -1
- data/spec/controllers/spree/checkout_controller_spec.rb +15 -16
- data/spec/controllers/spree/products_controller_spec.rb +1 -1
- data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -4
- data/spec/controllers/spree/user_registrations_controller_spec.rb +8 -8
- data/spec/controllers/spree/user_sessions_controller_spec.rb +17 -17
- data/spec/controllers/spree/users_controller_spec.rb +4 -4
- data/spec/features/account_spec.rb +10 -8
- data/spec/features/admin/password_reset_spec.rb +2 -4
- data/spec/features/admin/sign_in_spec.rb +5 -7
- data/spec/features/admin/sign_out_spec.rb +1 -1
- data/spec/features/admin_permissions_spec.rb +1 -1
- data/spec/features/change_email_spec.rb +1 -7
- data/spec/features/checkout_spec.rb +38 -63
- data/spec/features/confirmation_spec.rb +3 -5
- data/spec/features/order_spec.rb +9 -15
- data/spec/features/password_reset_spec.rb +2 -4
- data/spec/features/sign_in_spec.rb +7 -9
- data/spec/features/sign_out_spec.rb +16 -23
- data/spec/features/sign_up_spec.rb +6 -4
- data/spec/mailers/user_mailer_spec.rb +1 -1
- data/spec/models/user_spec.rb +5 -5
- data/spec/requests/spree/frontend/user_update_spec.rb +42 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/add_to_cart.rb +11 -4
- data/spec/support/authentication_helpers.rb +1 -1
- data/spec/support/capybara.rb +15 -8
- data/spree_auth_devise.gemspec +14 -10
- metadata +104 -74
- data/app/overrides/auth_shared_login_bar.rb +0 -6
- data/app/views/spree/shared/_login.html.erb +0 -18
- data/app/views/spree/shared/_user_form.html.erb +0 -17
- data/gemfiles/spree_3_2.gemfile +0 -8
- data/gemfiles/spree_3_7.gemfile +0 -9
- data/gemfiles/spree_4_0.gemfile +0 -8
- data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +0 -1
- data/lib/assets/javascripts/spree/frontend/account.js +0 -8
- data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +0 -2
- data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +0 -3
- data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +0 -3
- data/lib/controllers/frontend/spree/store_controller_decorator.rb +0 -7
- data/lib/views/frontend/spree/checkout/_new_user.html.erb +0 -20
- data/lib/views/frontend/spree/checkout/registration.html.erb +0 -25
- data/lib/views/frontend/spree/shared/_link_to_account.html.erb +0 -6
- data/lib/views/frontend/spree/users/edit.html.erb +0 -17
- data/lib/views/frontend/spree/users/show.html.erb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46ff8af21fa16c063b0f61f5993e37f93072587b1e663e58089b2ea0a028b51b
|
4
|
+
data.tar.gz: 6d7fa7607dd17ff3b6c5231bd8295c5fef51ea7620e1e459d199b39b42649858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eefe313a0b7cd621e9192d483624541790292872576927da6089350aaa14352faa00e0b2dd8f36d2920b9faf4776cc5287df6c5308d2bce9111ec95228f26a1
|
7
|
+
data.tar.gz: 3e941ccde2788291ec91709149786c03dab905cf142811186a43949c3ce6549b89306e8ceb7692070dbb1a7a92ef306ae0adc808d62bb18d1ad27404afbc24f0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
update_staging_repository:
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.6.3
|
7
|
+
steps:
|
8
|
+
- add_ssh_keys:
|
9
|
+
fingerprints:
|
10
|
+
- 54:50:5e:4e:80:6d:2e:26:43:c6:99:bd:39:b2:71:dc
|
11
|
+
- run: mkdir -p ~/.ssh
|
12
|
+
- run: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
13
|
+
- run: ssh-add -D
|
14
|
+
- run: ssh-add ~/.ssh/id_rsa_54505e4e806d2e2643c699bd39b271dc
|
15
|
+
- run: git clone -b master git@github.com:spark-solutions/spree-designs.git
|
16
|
+
- run: gem install bundler -v 1.17.3
|
17
|
+
- run:
|
18
|
+
command: bundle update spree_auth_devise
|
19
|
+
working_directory: ~/project/spree-designs
|
20
|
+
- run:
|
21
|
+
command: |
|
22
|
+
git config user.name 'AutoDeploy'
|
23
|
+
git config user.email 'autodeploy@sparksolutions.co'
|
24
|
+
working_directory: ~/project/spree-designs
|
25
|
+
- run:
|
26
|
+
command: |
|
27
|
+
git add -A
|
28
|
+
git commit -m "Auto-commit v#${CIRCLE_BUILD_NUM}"
|
29
|
+
working_directory: ~/project/spree-designs
|
30
|
+
- run:
|
31
|
+
command: git push origin master
|
32
|
+
working_directory: ~/project/spree-designs
|
33
|
+
|
34
|
+
workflows:
|
35
|
+
version: 2
|
36
|
+
update_staging_repository:
|
37
|
+
jobs:
|
38
|
+
- update_staging_repository:
|
39
|
+
filters:
|
40
|
+
branches:
|
41
|
+
only: master
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -17,36 +17,18 @@ language: ruby
|
|
17
17
|
|
18
18
|
rvm:
|
19
19
|
- 2.5.1
|
20
|
-
- 2.
|
21
|
-
- 2.3.7
|
20
|
+
# - 2.6.5
|
22
21
|
|
23
22
|
gemfile:
|
24
|
-
- gemfiles/
|
25
|
-
- gemfiles/spree_3_5.gemfile
|
26
|
-
- gemfiles/spree_3_7.gemfile
|
27
|
-
- gemfiles/spree_4_0.gemfile
|
23
|
+
- gemfiles/spree_4_1.gemfile
|
28
24
|
- gemfiles/spree_master.gemfile
|
29
25
|
|
30
26
|
matrix:
|
31
27
|
allow_failures:
|
32
28
|
- gemfile: gemfiles/spree_master.gemfile
|
33
|
-
exclude:
|
34
|
-
- rvm: 2.3.7
|
35
|
-
gemfile: gemfiles/spree_4_0.gemfile
|
36
|
-
- rvm: 2.4.4
|
37
|
-
gemfile: gemfiles/spree_4_0.gemfile
|
38
|
-
- rvm: 2.3.7
|
39
|
-
gemfile: gemfiles/spree_master.gemfile
|
40
|
-
- rvm: 2.4.4
|
41
|
-
gemfile: gemfiles/spree_master.gemfile
|
42
|
-
- rvm: 2.5.1
|
43
|
-
gemfile: gemfiles/spree_3_2.gemfile
|
44
|
-
- rvm: 2.5.1
|
45
|
-
gemfile: gemfiles/spree_3_2.gemfile
|
46
|
-
- rvm: 2.5.1
|
47
|
-
gemfile: gemfiles/spree_3_5.gemfile
|
48
29
|
|
49
30
|
before_install:
|
31
|
+
- gem update bundler
|
50
32
|
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
51
33
|
- wget -N https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip -P ~/
|
52
34
|
- unzip ~/chromedriver_linux64.zip -d ~/
|
data/Appraisals
CHANGED
@@ -1,25 +1,9 @@
|
|
1
|
-
appraise 'spree-
|
2
|
-
gem 'spree', '~> 3.2.0'
|
3
|
-
gem 'rails-controller-testing'
|
4
|
-
end
|
5
|
-
|
6
|
-
appraise 'spree-3-5' do
|
7
|
-
gem 'spree', '~> 3.5.0'
|
8
|
-
gem 'rails-controller-testing'
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise 'spree-3-7' do
|
12
|
-
gem 'sass-rails'
|
13
|
-
gem 'spree', '~> 3.7.0.rc3'
|
14
|
-
gem 'rails-controller-testing'
|
15
|
-
end
|
16
|
-
|
17
|
-
appraise 'spree-4-0' do
|
18
|
-
gem 'spree', github: 'spree/spree', tag: 'v4.0.0.beta'
|
1
|
+
appraise 'spree-4-1' do
|
19
2
|
gem 'rails-controller-testing'
|
3
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
20
4
|
end
|
21
5
|
|
22
6
|
appraise 'spree-master' do
|
23
|
-
gem 'spree', github: 'spree/spree', branch: 'master'
|
24
7
|
gem 'rails-controller-testing'
|
8
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
25
9
|
end
|
data/Gemfile
CHANGED
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
|
@@ -6,6 +6,30 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
|
|
6
6
|
include Spree::Core::ControllerHelpers::Order
|
7
7
|
include Spree::Core::ControllerHelpers::Store
|
8
8
|
|
9
|
+
before_action :set_current_order
|
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
|
+
|
9
33
|
protected
|
10
34
|
|
11
35
|
def after_confirmation_path_for(resource_name, resource)
|
@@ -10,6 +10,8 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
10
10
|
include SpreeI18n::ControllerLocaleHelper
|
11
11
|
end
|
12
12
|
|
13
|
+
before_action :set_current_order
|
14
|
+
|
13
15
|
# Overridden due to bug in Devise.
|
14
16
|
# respond_with resource, :location => new_session_path(resource_name)
|
15
17
|
# is generating bad url /session/new.user
|
@@ -11,6 +11,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before_action :check_permissions, only: [:edit, :update]
|
14
|
+
before_action :set_current_order
|
14
15
|
skip_before_action :require_no_authentication
|
15
16
|
|
16
17
|
# GET /resource/sign_up
|
@@ -29,7 +30,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
29
30
|
set_flash_message :notice, :signed_up
|
30
31
|
sign_up(resource_name, resource)
|
31
32
|
session[:spree_user_signup] = true
|
32
|
-
|
33
|
+
redirect_to_checkout_or_account_path(resource)
|
33
34
|
else
|
34
35
|
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}"
|
35
36
|
expire_data_after_sign_in!
|
@@ -75,9 +76,34 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
75
76
|
'devise.user_registrations'
|
76
77
|
end
|
77
78
|
|
79
|
+
def after_sign_up_path_for(resource)
|
80
|
+
after_sign_in_redirect(resource) if is_navigational_format?
|
81
|
+
end
|
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
|
+
|
78
90
|
private
|
79
91
|
|
80
92
|
def spree_user_params
|
81
93
|
params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
|
82
94
|
end
|
95
|
+
|
96
|
+
def after_sign_in_redirect(resource_or_scope)
|
97
|
+
stored_location_for(resource_or_scope) || account_path
|
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
|
83
109
|
end
|
@@ -10,6 +10,8 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
10
10
|
include SpreeI18n::ControllerLocaleHelper
|
11
11
|
end
|
12
12
|
|
13
|
+
before_action :set_current_order
|
14
|
+
|
13
15
|
def create
|
14
16
|
authenticate_spree_user!
|
15
17
|
|
@@ -17,7 +19,7 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
17
19
|
respond_to do |format|
|
18
20
|
format.html {
|
19
21
|
flash[:success] = Spree.t(:logged_in_succesfully)
|
20
|
-
redirect_back_or_default(
|
22
|
+
redirect_back_or_default(after_sign_in_redirect(spree_current_user))
|
21
23
|
}
|
22
24
|
format.js {
|
23
25
|
render json: { user: spree_current_user,
|
@@ -54,4 +56,24 @@ class Spree::UserSessionsController < Devise::SessionsController
|
|
54
56
|
redirect_to(session["spree_user_return_to"] || default)
|
55
57
|
session["spree_user_return_to"] = nil
|
56
58
|
end
|
59
|
+
|
60
|
+
def after_sign_in_redirect(resource_or_scope)
|
61
|
+
stored_location_for(resource_or_scope) || account_path
|
62
|
+
end
|
63
|
+
|
64
|
+
def respond_to_on_destroy
|
65
|
+
# We actually need to hardcode this as Rails default responder doesn't
|
66
|
+
# support returning empty response on GET request
|
67
|
+
respond_to do |format|
|
68
|
+
format.all { head :no_content }
|
69
|
+
format.any(*navigational_formats) { redirect_to after_sign_out_redirect(resource_name) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def after_sign_out_redirect(resource_or_scope)
|
74
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
75
|
+
router_name = Devise.mappings[scope].router_name
|
76
|
+
context = router_name ? send(router_name) : self
|
77
|
+
context.respond_to?(:login_path) ? context.login_path : "/"
|
78
|
+
end
|
57
79
|
end
|
@@ -1,22 +1,25 @@
|
|
1
1
|
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
2
|
+
|
3
|
+
<div class="container user-passwords">
|
4
|
+
<div class="row">
|
5
|
+
<div class="col-lg-6 offset-lg-3">
|
6
|
+
<div class="card mb-3 user-passwords-no-border">
|
7
|
+
<h3 class="spree-mb-large spree-mt-large spree-header"><%= Spree.t(:change_your_password) %></h3>
|
8
|
+
<div class="card-body">
|
9
|
+
<%= form_for @spree_user, as: :spree_user, url: spree.update_password_path, method: :put do |f| %>
|
10
|
+
<div class="form-group">
|
11
|
+
<%= f.label :password, Spree.t(:password), class: 'spree-flat-label' %>
|
12
|
+
<%= f.password_field :password, class: "spree-flat-input" %>
|
13
|
+
</div>
|
14
|
+
<div class="form-group">
|
15
|
+
<%= f.label :password_confirmation, Spree.t(:confirm_password), class: 'spree-flat-label' %>
|
16
|
+
<%= f.password_field :password_confirmation, class: "spree-flat-input" %>
|
17
|
+
</div>
|
18
|
+
<%= f.hidden_field :reset_password_token %>
|
19
|
+
<%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block spree-btn mt-2' %>
|
20
|
+
<% end %>
|
16
21
|
</div>
|
17
|
-
|
18
|
-
<%= f.submit Spree.t(:update), :class => 'btn btn-lg btn-success btn-block' %>
|
19
|
-
<% end %>
|
22
|
+
</div>
|
20
23
|
</div>
|
21
24
|
</div>
|
22
25
|
</div>
|
@@ -1,21 +1,23 @@
|
|
1
1
|
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
|
2
|
-
<div class="col-lg-6 offset-lg-3" id="forgot-password">
|
3
|
-
<div class="card mb-3">
|
4
|
-
<div class="card-header">
|
5
|
-
<h3 class="card-title mb-0 h6"><%= Spree.t(:forgot_password) %></h3>
|
6
|
-
</div>
|
7
|
-
<div class="card-body">
|
8
|
-
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
9
2
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<div>
|
16
|
-
|
3
|
+
<div class="container user-passwords">
|
4
|
+
<div class="row">
|
5
|
+
<div class="col-lg-6 offset-lg-3" id="forgot-password">
|
6
|
+
<div class="card mb-3 user-passwords-no-border">
|
7
|
+
<h3 class="spree-mb-large spree-mt-large spree-header"><%= Spree.t(:forgot_password) %></h3>
|
8
|
+
<div class="card-body">
|
9
|
+
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
10
|
+
|
11
|
+
<%= form_for Spree.user_class.new, as: :spree_user, url: spree.reset_password_path do |f| %>
|
12
|
+
<div class="form-group">
|
13
|
+
<%= f.email_field :email, class: "spree-flat-input", placeholder: Spree.t(:email) %>
|
14
|
+
</div>
|
15
|
+
<div>
|
16
|
+
<%= f.submit Spree.t(:reset_password), class: 'btn btn-primary btn-block spree-btn mt-2' %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
17
19
|
</div>
|
18
|
-
|
20
|
+
</div>
|
19
21
|
</div>
|
20
22
|
</div>
|
21
23
|
</div>
|
@@ -1,22 +1,17 @@
|
|
1
1
|
<% @body_id = 'signup' %>
|
2
|
-
<%= render :
|
2
|
+
<%= render partial: 'spree/shared/error_messages', locals: { target: @user } %>
|
3
3
|
<div class="col-lg-6 offset-lg-3">
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<div data-hook="signup_inside_form">
|
11
|
-
<%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
|
12
|
-
<div><%= f.submit Spree.t(:create), :class => 'btn btn-lg btn-success btn-block' %></div>
|
13
|
-
</div>
|
14
|
-
<% end %>
|
15
|
-
<div class="text-center">
|
16
|
-
<%= Spree.t(:or) %>
|
17
|
-
<%= link_to Spree.t(:login_as_existing), spree.login_path %>
|
18
|
-
</div>
|
19
|
-
<div data-hook="login_extras"></div>
|
4
|
+
<h3 class="spree-header spree-mb-large spree-mt-large"><%= Spree.t(:new_customer) %></h3>
|
5
|
+
<div id="new-customer" data-hook="login">
|
6
|
+
<%= form_for resource, as: :spree_user, url: spree.registration_path do |f| %>
|
7
|
+
<div data-hook="signup_inside_form">
|
8
|
+
<%= render partial: 'spree/shared/user_form', locals: { f: f, remember_me_field: true } %>
|
9
|
+
<div><%= f.submit Spree.t(:sign_up), class: 'btn btn-primary btn-block spree-btn mb-5' %></div>
|
20
10
|
</div>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<h3 class="spree-header header-sm spree-mt-medium mb-3 mb-sm-4 mb-xl-4"><%= Spree.t('already_have_account') %></h3>
|
14
|
+
<%= link_to Spree.t(:log_in), spree.login_path, class: 'btn btn-block btn-outline-primary spree-btn spree-mb-large' %>
|
15
|
+
<div data-hook="login_extras"></div>
|
21
16
|
</div>
|
22
17
|
</div>
|
@@ -1,17 +1,16 @@
|
|
1
1
|
<% @body_id = 'login' %>
|
2
|
-
<div class="
|
3
|
-
<div class="
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<%= render :partial => 'spree/shared/login' %>
|
9
|
-
<div class="text-center">
|
10
|
-
<%= Spree.t(:or) %>
|
11
|
-
<%= link_to Spree.t(:create_a_new_account), spree.signup_path %> |
|
12
|
-
<%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
|
13
|
-
</div>
|
2
|
+
<div class="container user-sessions user-sessions-new">
|
3
|
+
<div class="row">
|
4
|
+
<div class="col-lg-6 offset-lg-3">
|
5
|
+
<div class="mb-3">
|
6
|
+
<div id="existing-customer" data-hook="login">
|
7
|
+
<%= render partial: 'spree/shared/login' %>
|
14
8
|
<div data-hook="login_extras"></div>
|
9
|
+
</div>
|
10
|
+
<div class="col-lg-11 mx-auto" data-hook="registration">
|
11
|
+
<%= render partial: 'spree/shared/registration', locals: { registration_button: 'registration-button' } %>
|
12
|
+
</div>
|
15
13
|
</div>
|
14
|
+
</div>
|
16
15
|
</div>
|
17
16
|
</div>
|
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',
|
@@ -27,12 +27,11 @@ Spree::Core::Engine.add_routes do
|
|
27
27
|
get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
|
28
28
|
put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
|
29
29
|
|
30
|
-
get '/account_link' => 'store#account_link'
|
31
30
|
resource :account, controller: 'users'
|
32
31
|
|
33
32
|
namespace :admin, path: Spree.admin_path do
|
34
33
|
devise_for :spree_user,
|
35
|
-
class_name:
|
34
|
+
class_name: Spree.user_class.to_s,
|
36
35
|
controllers: { sessions: 'spree/admin/user_sessions',
|
37
36
|
passwords: 'spree/admin/user_passwords' },
|
38
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
|
@@ -1,16 +1,20 @@
|
|
1
1
|
class Spree::UsersController < Spree::StoreController
|
2
|
-
|
3
|
-
prepend_before_action :load_object, only: [:show, :edit, :update]
|
2
|
+
before_action :set_current_order, except: :show
|
4
3
|
prepend_before_action :authorize_actions, only: :new
|
5
4
|
|
6
5
|
include Spree::Core::ControllerHelpers
|
7
6
|
|
8
7
|
def show
|
8
|
+
load_object
|
9
9
|
@orders = @user.orders.complete.order('completed_at desc')
|
10
10
|
end
|
11
11
|
|
12
|
+
def edit
|
13
|
+
load_object
|
14
|
+
end
|
15
|
+
|
12
16
|
def create
|
13
|
-
@user = Spree
|
17
|
+
@user = Spree.user_class.new(user_params)
|
14
18
|
if @user.save
|
15
19
|
|
16
20
|
if current_order
|
@@ -24,10 +28,11 @@ class Spree::UsersController < Spree::StoreController
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def update
|
27
|
-
|
31
|
+
load_object
|
32
|
+
if @user.update(user_params)
|
28
33
|
if params[:user][:password].present?
|
29
34
|
# this logic needed b/c devise wants to log us out after password changes
|
30
|
-
Spree
|
35
|
+
Spree.user_class.reset_password_by_token(params[:user])
|
31
36
|
if Spree::Auth::Config[:signout_after_password_change]
|
32
37
|
sign_in(@user, event: :authentication)
|
33
38
|
else
|
@@ -52,7 +57,7 @@ class Spree::UsersController < Spree::StoreController
|
|
52
57
|
end
|
53
58
|
|
54
59
|
def authorize_actions
|
55
|
-
authorize! params[:action].to_sym, Spree
|
60
|
+
authorize! params[:action].to_sym, Spree.user_class.new
|
56
61
|
end
|
57
62
|
|
58
63
|
def accurate_title
|
@@ -10,10 +10,6 @@ module Spree
|
|
10
10
|
paths.flatten
|
11
11
|
end
|
12
12
|
|
13
|
-
def add_javascripts
|
14
|
-
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_auth\n"
|
15
|
-
end
|
16
|
-
|
17
13
|
def generate_devise_key
|
18
14
|
return if ENV['CI']
|
19
15
|
template 'config/initializers/devise.rb', 'config/initializers/devise.rb'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Spree
|
2
|
+
module TestingSupport
|
3
|
+
module AuthHelpers
|
4
|
+
def log_in(email:, password:, remember_me: true)
|
5
|
+
visit spree.login_path
|
6
|
+
|
7
|
+
fill_in 'Email', with: email
|
8
|
+
fill_in 'Password', with: password
|
9
|
+
|
10
|
+
# Regression test for #1257
|
11
|
+
first('label', text: 'Remember me').click if remember_me
|
12
|
+
click_button 'Log in'
|
13
|
+
|
14
|
+
expect(page).to have_content 'Logged in successfully'
|
15
|
+
end
|
16
|
+
|
17
|
+
def log_out
|
18
|
+
show_user_menu
|
19
|
+
click_link 'LOG OUT'
|
20
|
+
|
21
|
+
expect(page).to have_content 'Signed out successfully'
|
22
|
+
end
|
23
|
+
|
24
|
+
def show_user_menu
|
25
|
+
find("button[aria-label='Show user menu']").click
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_user_account
|
29
|
+
within '#nav-bar' do
|
30
|
+
show_user_menu
|
31
|
+
click_link 'MY ACCOUNT'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spree
|
2
|
+
module TestingSupport
|
3
|
+
module CheckoutHelpers
|
4
|
+
def fill_in_address
|
5
|
+
address = 'order_bill_address_attributes'
|
6
|
+
fill_in "#{address}_firstname", with: 'Ryan'
|
7
|
+
fill_in "#{address}_lastname", with: 'Bigg'
|
8
|
+
fill_in "#{address}_address1", with: '143 Swan Street'
|
9
|
+
fill_in "#{address}_city", with: 'Richmond'
|
10
|
+
select country.name, from: "#{address}_country_id"
|
11
|
+
select state.name, from: "#{address}_state_id"
|
12
|
+
fill_in "#{address}_zipcode", with: '12345'
|
13
|
+
fill_in "#{address}_phone", with: '(555) 555-5555'
|
14
|
+
end
|
15
|
+
|
16
|
+
def fill_in_credit_card_info(invalid: false)
|
17
|
+
fill_in 'name_on_card', with: 'Spree Commerce'
|
18
|
+
fill_in 'card_number', with: invalid ? '123' : '4111 1111 1111 1111'
|
19
|
+
fill_in 'card_expiry', with: '12 / 24'
|
20
|
+
fill_in 'card_code', with: '123'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|