passwordless 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2242a4b95f1a99d5be1b889539dc6dd9f1eda711ce616f3b090f12dd68337254
4
- data.tar.gz: afd9ea1fd2d3b3f15f10a4772d231c53adfd524e22de00d833a9183b34d69397
3
+ metadata.gz: 6dc17e0a0f2696a647ba5f5dffaededf6494a48f4cd3393135e041c91b3955f0
4
+ data.tar.gz: b27244139169a60b25c1251321aa6576d7fbbe7e9e122cb5886041f7a60a4886
5
5
  SHA512:
6
- metadata.gz: 9b2ceb4c68972744e10ac6dd56e2e863b5e229bb31053b7159a16c020a2cfa55ffe1affcbef92ca52ee03de79d4d675cb5b3f4340e1c888e064e9ab246f3e455
7
- data.tar.gz: 7dd102d25dd4cbb60ab73d30732f78a6cd1d6757e345e3b304c9b1abe4394b6b1d883c1368bd7eaa12ecee986ecdfabf3d82cea081048694807388fc5a1bfd69
6
+ metadata.gz: 66be83e8a5b1f8cd06d83196d94ce42e9fe25dbbd49a650ca553c8874ac47503758c782b10831187d7005666fbe73e1468fea82a9c6cdad21dae8abe85cfca22
7
+ data.tar.gz: 266ec15bbc186604c4ab0eda90171499052fa22e11d8eeb0c8f96196fe3363ee45c42d183d76a16dc90670308a1ae9a7bc84bfbb321a8c01fca815ae7e24b6cf
data/README.md CHANGED
@@ -70,7 +70,7 @@ class ApplicationController < ActionController::Base
70
70
  def require_user!
71
71
  return if current_user
72
72
  save_passwordless_redirect_location!(User) # <-- optional, see below
73
- redirect_to root_path, flash: { error: 'You are not worthy!' }
73
+ redirect_to root_path, alert: "You are not worthy!"
74
74
  end
75
75
  end
76
76
  ```
@@ -237,7 +237,7 @@ class ApplicationController < ActionController::Base
237
237
  def require_user!
238
238
  return if current_user
239
239
  save_passwordless_redirect_location!(User) # <-- this one!
240
- redirect_to root_path, flash: {error: 'You are not worthy!'}
240
+ redirect_to root_path, alert: "You are not worthy!"
241
241
  end
242
242
  end
243
243
  ```
@@ -105,11 +105,11 @@ module Passwordless
105
105
  protected
106
106
 
107
107
  def passwordless_sign_out_redirect_path
108
- Passwordless.config.sign_out_redirect_path
108
+ call_or_return(Passwordless.config.sign_out_redirect_path)
109
109
  end
110
110
 
111
111
  def passwordless_failure_redirect_path
112
- Passwordless.config.failure_redirect_path
112
+ call_or_return(Passwordless.config.failure_redirect_path)
113
113
  end
114
114
 
115
115
  def passwordless_query_redirect_path
@@ -120,10 +120,14 @@ module Passwordless
120
120
  end
121
121
 
122
122
  def passwordless_success_redirect_path
123
- return Passwordless.config.success_redirect_path unless Passwordless.config.redirect_back_after_sign_in
123
+ success_redirect_path = call_or_return(Passwordless.config.success_redirect_path)
124
124
 
125
- session_redirect_url = reset_passwordless_redirect_location!(authenticatable_class)
126
- passwordless_query_redirect_path || session_redirect_url || Passwordless.config.success_redirect_path
125
+ if Passwordless.config.redirect_back_after_sign_in
126
+ session_redirect_url = reset_passwordless_redirect_location!(authenticatable_class)
127
+ return passwordless_query_redirect_path || session_redirect_url || success_redirect_path
128
+ end
129
+
130
+ success_redirect_path
127
131
  end
128
132
 
129
133
  private
@@ -164,6 +168,10 @@ module Passwordless
164
168
  authenticatable_type.constantize
165
169
  end
166
170
 
171
+ def call_or_return(value)
172
+ value.respond_to?(:call) ? value.call : value
173
+ end
174
+
167
175
  def find_authenticatable
168
176
  if authenticatable_class.respond_to?(:fetch_resource_for_passwordless)
169
177
  authenticatable_class.fetch_resource_for_passwordless(normalized_email_param)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Passwordless
4
4
  # :nodoc:
5
- VERSION = "1.3.0"
5
+ VERSION = "1.4.0"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passwordless
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-24 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails