solidus_auth_devise 2.5.5 → 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eabe96f35091dbe9f4cac913044f4eb301bd049adb5cb1f8b7b98616847cdf0f
4
- data.tar.gz: '009afc8b8585d494940949bebaae6dc3ffdf2f80fb26f16189ecd1299c65c669'
3
+ metadata.gz: 7714facb5fe5f4230194a4680c5f63a5f3257726811ec9a2ac337f96b20b297a
4
+ data.tar.gz: fac0bd47a9a25e211bf56135a334e5f1e3b9525513f290b0b18016e8d5409446
5
5
  SHA512:
6
- metadata.gz: 7991cf3c2104f5e1cb21fe59d251a0d38c060ffb1b98788abc21598419034d19307879e0ebc075c1b9683a8c77bf1c2cb94438f21f197e6acb3a8105da0c76a8
7
- data.tar.gz: 0abb460d4822728befdbfa648d3b190412968b3e75049e64f05b3b3304368ec4212cfb5feaedb7c3f3b1a92b8f256e7815c8daa37f82611eadb36be3ca0ab51c
6
+ metadata.gz: eb4378a3029e4db8ba943cdb5a4a54fe5b2303a8d2dfe07d8cc7e4b16609987aa9927b5a84b47844cf5122652899a77293a25440f49f42bb65d1b38711d063e8
7
+ data.tar.gz: 0332cdb250463314283e1ee3da8c3ed2ce697d0851d6c3aef946183d53c647f1d533a3f8793567fe43d15d07451890104142faaeb9b5ce74e651a7dc5f83dafb
@@ -17,7 +17,7 @@ class Spree::Admin::UserSessionsController < Devise::SessionsController
17
17
  respond_to do |format|
18
18
  format.html {
19
19
  flash[:success] = I18n.t('spree.logged_in_succesfully')
20
- redirect_to stored_spree_user_location_or(after_sign_in_path_for(spree_current_user))
20
+ redirect_back_or_default(after_sign_in_path_for(spree_current_user))
21
21
  }
22
22
  format.js {
23
23
  user = resource.record
@@ -47,4 +47,9 @@ class Spree::Admin::UserSessionsController < Devise::SessionsController
47
47
  def accurate_title
48
48
  I18n.t('spree.login')
49
49
  end
50
+
51
+ def redirect_back_or_default(default)
52
+ redirect_to(session["spree_user_return_to"] || default)
53
+ session["spree_user_return_to"] = nil
54
+ end
50
55
  end
@@ -19,7 +19,7 @@ class Spree::UserSessionsController < Devise::SessionsController
19
19
  respond_to do |format|
20
20
  format.html do
21
21
  flash[:success] = I18n.t('spree.logged_in_succesfully')
22
- redirect_to stored_spree_user_location_or(after_sign_in_path_for(spree_current_user))
22
+ redirect_back_or_default(after_sign_in_path_for(spree_current_user))
23
23
  end
24
24
  format.js { render success_json }
25
25
  end
@@ -49,6 +49,11 @@ class Spree::UserSessionsController < Devise::SessionsController
49
49
  I18n.t('spree.login')
50
50
  end
51
51
 
52
+ def redirect_back_or_default(default)
53
+ redirect_to(session["spree_user_return_to"] || default)
54
+ session["spree_user_return_to"] = nil
55
+ end
56
+
52
57
  def success_json
53
58
  {
54
59
  json: {
@@ -17,7 +17,7 @@ class Spree::UsersController < Spree::StoreController
17
17
  session[:guest_token] = nil
18
18
  end
19
19
 
20
- redirect_to stored_spree_user_location_or(root_url)
20
+ redirect_back_or_default(root_url)
21
21
  else
22
22
  render :new
23
23
  end
@@ -45,6 +45,7 @@ module Spree
45
45
  def check_registration
46
46
  return unless registration_required?
47
47
 
48
+ store_location
48
49
  redirect_to spree.checkout_registration_path
49
50
  end
50
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusAuthDevise
4
- VERSION = '2.5.5'
4
+ VERSION = '2.5.6'
5
5
  end
@@ -59,6 +59,7 @@ module Spree
59
59
  redirect_to spree.admin_unauthorized_path
60
60
  end
61
61
  else
62
+ store_location
62
63
 
63
64
  if Spree::Auth::Engine.redirect_back_on_unauthorized?
64
65
  redirect_back(fallback_location: spree.admin_login_path)
@@ -69,6 +70,7 @@ module Spree
69
70
  end
70
71
  end
71
72
 
73
+
72
74
  def self.prepare_frontend
73
75
  Spree::BaseController.unauthorized_redirect = -> do
74
76
  if spree_current_user
@@ -80,6 +82,7 @@ module Spree
80
82
  redirect_to spree.unauthorized_path
81
83
  end
82
84
  else
85
+ store_location
83
86
 
84
87
  if Spree::Auth::Engine.redirect_back_on_unauthorized?
85
88
  redirect_back(fallback_location: spree.login_path)
@@ -23,30 +23,5 @@ module Spree
23
23
  to: :spree,
24
24
  prefix: :spree
25
25
  end
26
-
27
- private
28
-
29
- def authenticate_spree_user!
30
- store_spree_user_location! if storable_spree_user_location?
31
-
32
- super
33
- end
34
-
35
- # It's important that the location is NOT stored if:
36
- # - The request method is not GET (non idempotent)
37
- # - The request is handled by a Devise controller such as Devise::SessionsController as that could cause an
38
- # infinite redirect loop.
39
- # - The request is an Ajax request as this can lead to very unexpected behaviour.
40
- def storable_spree_user_location?
41
- request.get? && is_navigational_format? && !devise_controller? && !request.xhr?
42
- end
43
-
44
- def store_spree_user_location!
45
- store_location_for(:spree_current_user, request.fullpath)
46
- end
47
-
48
- def stored_spree_user_location_or(fallback_location)
49
- stored_location_for(:spree_current_user) || fallback_location
50
- end
51
26
  end
52
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.5
4
+ version: 2.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-19 00:00:00.000000000 Z
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -142,7 +142,7 @@ dependencies:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
- description:
145
+ description:
146
146
  email: contact@solidus.io
147
147
  executables: []
148
148
  extensions: []
@@ -283,7 +283,7 @@ metadata:
283
283
  homepage_uri: https://github.com/solidusio/solidus_auth_devise
284
284
  source_code_uri: https://github.com/solidusio/solidus_auth_devise
285
285
  changelog_uri: https://github.com/solidusio/solidus_auth_devise/blob/master/CHANGELOG.md
286
- post_install_message:
286
+ post_install_message:
287
287
  rdoc_options: []
288
288
  require_paths:
289
289
  - lib
@@ -301,8 +301,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  - !ruby/object:Gem::Version
302
302
  version: '0'
303
303
  requirements: []
304
- rubygems_version: 3.3.7
305
- signing_key:
304
+ rubygems_version: 3.2.32
305
+ signing_key:
306
306
  specification_version: 4
307
307
  summary: Provides authentication and authorization services for use with Solidus by
308
308
  using Devise and CanCan.