passwordless 1.4.0 → 1.5.0

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: 6dc17e0a0f2696a647ba5f5dffaededf6494a48f4cd3393135e041c91b3955f0
4
- data.tar.gz: b27244139169a60b25c1251321aa6576d7fbbe7e9e122cb5886041f7a60a4886
3
+ metadata.gz: 472a9d736665b6a1e1a71bf5175214f3acc414e0c918a33825c98a1d7ac02624
4
+ data.tar.gz: 9e12898751e19fc7104c62826eaf7c9ee4e17a14a12efc66419eab4850dae720
5
5
  SHA512:
6
- metadata.gz: 66be83e8a5b1f8cd06d83196d94ce42e9fe25dbbd49a650ca553c8874ac47503758c782b10831187d7005666fbe73e1468fea82a9c6cdad21dae8abe85cfca22
7
- data.tar.gz: 266ec15bbc186604c4ab0eda90171499052fa22e11d8eeb0c8f96196fe3363ee45c42d183d76a16dc90670308a1ae9a7bc84bfbb321a8c01fca815ae7e24b6cf
6
+ metadata.gz: 58b5bac3c0260d68a86fc7d9c3258457405a3670e0f8333959aa1ee54774ab68774728522d2e40c5d3b67a430f3b952af8903bb5d29b4ee12b6a291e3415fd17
7
+ data.tar.gz: 42252595f95f48896cd08ec1be77a28657553ae287cc52213bed5cc343c38121bf12c8aba1db8ea002237ea8b5c1d706a8fc8f10dc7b9522c72c80218e4d35a5
@@ -119,8 +119,15 @@ module Passwordless
119
119
  nil
120
120
  end
121
121
 
122
- def passwordless_success_redirect_path
123
- success_redirect_path = call_or_return(Passwordless.config.success_redirect_path)
122
+ def passwordless_success_redirect_path(authenticatable)
123
+ success_redirect_path = Passwordless.config.success_redirect_path
124
+
125
+ if success_redirect_path.respond_to?(:call)
126
+ success_redirect_path = call_or_return(
127
+ success_redirect_path,
128
+ *[authenticatable].first(success_redirect_path.arity)
129
+ )
130
+ end
124
131
 
125
132
  if Passwordless.config.redirect_back_after_sign_in
126
133
  session_redirect_url = reset_passwordless_redirect_location!(authenticatable_class)
@@ -142,7 +149,11 @@ module Passwordless
142
149
  def authenticate_and_sign_in(session, token)
143
150
  if session.authenticate(token)
144
151
  sign_in(session)
145
- redirect_to(passwordless_success_redirect_path, status: :see_other, **redirect_to_options)
152
+ redirect_to(
153
+ passwordless_success_redirect_path(session.authenticatable),
154
+ status: :see_other,
155
+ **redirect_to_options
156
+ )
146
157
  else
147
158
  flash[:error] = I18n.t("passwordless.sessions.errors.invalid_token")
148
159
  render(status: :forbidden, action: "show")
@@ -168,8 +179,12 @@ module Passwordless
168
179
  authenticatable_type.constantize
169
180
  end
170
181
 
171
- def call_or_return(value)
172
- value.respond_to?(:call) ? value.call : value
182
+ def call_or_return(value, *args)
183
+ if value.respond_to?(:call)
184
+ instance_exec(*args, &value)
185
+ else
186
+ value
187
+ end
173
188
  end
174
189
 
175
190
  def find_authenticatable
@@ -10,7 +10,7 @@ module Passwordless
10
10
  # @param session [Session] An instance of Passwordless::Session
11
11
  # @param token [String] The token in plaintext. Falls back to `session.token` hoping it
12
12
  # is still in memory (optional)
13
- def sign_in(session, token = nil)
13
+ def sign_in(session, token = nil, url_options = {})
14
14
  @token = token || session.token
15
15
 
16
16
  @magic_link = Passwordless.context.url_for(
@@ -18,6 +18,7 @@ module Passwordless
18
18
  action: "confirm",
19
19
  id: session.to_param,
20
20
  token: @token,
21
+ **url_options,
21
22
  **default_url_options
22
23
  )
23
24
 
@@ -75,6 +75,10 @@ if defined?(ActionDispatch::SystemTestCase)
75
75
  ActionDispatch::SystemTestCase.send(:include, ::Passwordless::TestHelpers::SystemTestCase)
76
76
  end
77
77
 
78
+ if defined?(ActionDispatch::IntegrationTest)
79
+ ActionDispatch::IntegrationTest.send(:include, ::Passwordless::TestHelpers::RequestTestCase)
80
+ end
81
+
78
82
  if defined?(RSpec)
79
83
  RSpec.configure do |config|
80
84
  config.include(::Passwordless::TestHelpers::ControllerTestCase, type: :controller)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Passwordless
4
4
  # :nodoc:
5
- VERSION = "1.4.0"
5
+ VERSION = "1.5.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.4.0
4
+ version: 1.5.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-26 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.5.5
94
+ rubygems_version: 3.5.6
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Add authentication to your app without all the ickyness of passwords.