passwordless 1.4.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/passwordless/sessions_controller.rb +27 -11
- data/app/mailers/passwordless/mailer.rb +2 -1
- data/app/models/passwordless/session.rb +2 -1
- data/app/views/passwordless/sessions/show.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/db/migrate/20171104221735_create_passwordless_sessions.rb +1 -1
- data/lib/passwordless/test_helpers.rb +4 -0
- data/lib/passwordless/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44758dfedcb5f0b737a6892abdb754751f14d4da6d0c4e7e3ae9fa41d1b544ee
|
4
|
+
data.tar.gz: 01e6534d9d3f8e11ff1f13e908c62a096fc32129a1f34df5a75defa97b7a0b31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29e04ae936111350bf9673b2fd38f88e47006b72bcdd4aac5a38595623ab93558ab03e0a62677197d21f56e5370f38cc9fa5b5cc44bd8d8bdecf43e5ee66932d
|
7
|
+
data.tar.gz: 0701f4569d5e37ca19d42eb1afe00bd4b99fb68a1e2951ff9ec419221d32fb559e012cbc80115013b94cb316b5b98c70f32e862ce448cc2985464a39f73d9e4a
|
@@ -30,19 +30,20 @@ module Passwordless
|
|
30
30
|
Passwordless.context.path_for(
|
31
31
|
@session,
|
32
32
|
id: @session.to_param,
|
33
|
-
action: "show"
|
33
|
+
action: "show",
|
34
|
+
**default_url_options
|
34
35
|
),
|
35
36
|
flash: {notice: I18n.t("passwordless.sessions.create.email_sent")}
|
36
37
|
)
|
37
38
|
else
|
38
|
-
flash
|
39
|
+
flash.alert = I18n.t("passwordless.sessions.create.error")
|
39
40
|
render(:new, status: :unprocessable_entity)
|
40
41
|
end
|
41
42
|
|
42
43
|
rescue ActiveRecord::RecordNotFound
|
43
44
|
@session = Session.new
|
44
45
|
|
45
|
-
flash
|
46
|
+
flash.alert = I18n.t("passwordless.sessions.create.not_found")
|
46
47
|
render(:new, status: :not_found)
|
47
48
|
end
|
48
49
|
|
@@ -119,8 +120,15 @@ module Passwordless
|
|
119
120
|
nil
|
120
121
|
end
|
121
122
|
|
122
|
-
def passwordless_success_redirect_path
|
123
|
-
success_redirect_path =
|
123
|
+
def passwordless_success_redirect_path(authenticatable)
|
124
|
+
success_redirect_path = Passwordless.config.success_redirect_path
|
125
|
+
|
126
|
+
if success_redirect_path.respond_to?(:call)
|
127
|
+
success_redirect_path = call_or_return(
|
128
|
+
success_redirect_path,
|
129
|
+
*[authenticatable].first(success_redirect_path.arity)
|
130
|
+
)
|
131
|
+
end
|
124
132
|
|
125
133
|
if Passwordless.config.redirect_back_after_sign_in
|
126
134
|
session_redirect_url = reset_passwordless_redirect_location!(authenticatable_class)
|
@@ -142,17 +150,21 @@ module Passwordless
|
|
142
150
|
def authenticate_and_sign_in(session, token)
|
143
151
|
if session.authenticate(token)
|
144
152
|
sign_in(session)
|
145
|
-
redirect_to(
|
153
|
+
redirect_to(
|
154
|
+
passwordless_success_redirect_path(session.authenticatable),
|
155
|
+
status: :see_other,
|
156
|
+
**redirect_to_options
|
157
|
+
)
|
146
158
|
else
|
147
|
-
flash
|
159
|
+
flash.alert = I18n.t("passwordless.sessions.errors.invalid_token")
|
148
160
|
render(status: :forbidden, action: "show")
|
149
161
|
end
|
150
162
|
|
151
163
|
rescue Errors::TokenAlreadyClaimedError
|
152
|
-
flash
|
164
|
+
flash.alert = I18n.t("passwordless.sessions.errors.token_claimed")
|
153
165
|
redirect_to(passwordless_failure_redirect_path, status: :see_other, **redirect_to_options)
|
154
166
|
rescue Errors::SessionTimedOutError
|
155
|
-
flash
|
167
|
+
flash.alert = I18n.t("passwordless.sessions.errors.session_expired")
|
156
168
|
redirect_to(passwordless_failure_redirect_path, status: :see_other, **redirect_to_options)
|
157
169
|
end
|
158
170
|
|
@@ -168,8 +180,12 @@ module Passwordless
|
|
168
180
|
authenticatable_type.constantize
|
169
181
|
end
|
170
182
|
|
171
|
-
def call_or_return(value)
|
172
|
-
value.respond_to?(:call)
|
183
|
+
def call_or_return(value, *args)
|
184
|
+
if value.respond_to?(:call)
|
185
|
+
instance_exec(*args, &value)
|
186
|
+
else
|
187
|
+
value
|
188
|
+
end
|
173
189
|
end
|
174
190
|
|
175
191
|
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
|
|
data/config/locales/en.yml
CHANGED
@@ -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)
|
data/lib/passwordless/version.rb
CHANGED
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
|
+
version: 1.6.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-
|
11
|
+
date: 2024-04-25 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.
|
94
|
+
rubygems_version: 3.5.9
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Add authentication to your app without all the ickyness of passwords.
|