passwordless 0.9.0 → 0.10.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 +4 -4
- data/README.md +17 -5
- data/app/controllers/passwordless/sessions_controller.rb +4 -5
- data/app/mailers/passwordless/mailer.rb +2 -2
- data/lib/passwordless.rb +1 -0
- data/lib/passwordless/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c45a41b4be30c959c37b50ef8013f4055c97ae516e4b8297b4f56607836cc09b
|
4
|
+
data.tar.gz: 7b0c50e087c5be36e5e89476764a407767aee4851fcb38c0b744bd532be8e982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b35ef690ecd6b37106d785ccb71693606387a8fcc48d5ea115b9d035211b8225d551291d3c64abdb89517cb0ceea17d31807d40ef6f168a9f5df742fd27b8d65
|
7
|
+
data.tar.gz: 8d8ba39b3711905ea36f5f20c009a26b42bcea43ed1bd1185ac56c0053e7afdb6fdf786f123fa8c01b2c095ec3104637d5017791056960293869053ff0b248a3
|
data/README.md
CHANGED
@@ -122,6 +122,15 @@ app/views/passwordless/sessions/create.html.erb
|
|
122
122
|
app/views/passwordless/mailer/magic_link.text.erb
|
123
123
|
```
|
124
124
|
|
125
|
+
If you'd like to let the user know whether or not a record was found, `@resource` is provided to the view. You may override `app/views/passwordless/session/create.html.erb` for example like so:
|
126
|
+
```erb
|
127
|
+
<% if @resource.present? %>
|
128
|
+
<p>User found, check your inbox</p>
|
129
|
+
<% else %>
|
130
|
+
<p>No user found with the provided email address</p>
|
131
|
+
<% end %>
|
132
|
+
```
|
133
|
+
|
125
134
|
See [the bundled views](https://github.com/mikker/passwordless/tree/master/app/views/passwordless).
|
126
135
|
|
127
136
|
### Registering new users
|
@@ -221,19 +230,22 @@ end
|
|
221
230
|
|
222
231
|
## Configuration
|
223
232
|
|
224
|
-
The following configuration parameters are supported.
|
233
|
+
The following configuration parameters are supported. You can override these for example in `initializers/passwordless.rb`.
|
234
|
+
|
235
|
+
The default values are shown below. It's recommended to only include the ones that you specifically want to override.
|
225
236
|
|
226
237
|
```ruby
|
227
238
|
Passwordless.default_from_address = "CHANGE_ME@example.com"
|
228
|
-
Passwordless.
|
239
|
+
Passwordless.parent_mailer = "ActionMailer::Base"
|
240
|
+
Passwordless.token_generator = Passwordless::UrlSafeBase64Generator.new # Used to generate magic link tokens.
|
229
241
|
Passwordless.restrict_token_reuse = false # By default a magic link token can be used multiple times.
|
230
242
|
Passwordless.redirect_back_after_sign_in = true # When enabled the user will be redirected to their previous page, or a page specified by the `destination_path` query parameter, if available.
|
231
243
|
|
232
|
-
Passwordless.expires_at = lambda { 1.year.from_now } # How long until a
|
233
|
-
Passwordless.timeout_at = lambda { 1.hour.from_now } # How long until a
|
244
|
+
Passwordless.expires_at = lambda { 1.year.from_now } # How long until a passwordless session expires.
|
245
|
+
Passwordless.timeout_at = lambda { 1.hour.from_now } # How long until a magic link expires.
|
234
246
|
|
235
247
|
# Default redirection paths
|
236
|
-
Passwordless.success_redirect_path = '/' # When a user succeeds in logging in.
|
248
|
+
Passwordless.success_redirect_path = '/' # When a user succeeds in logging in.
|
237
249
|
Passwordless.failure_redirect_path = '/' # When a a login is failed for any reason.
|
238
250
|
Passwordless.sign_out_redirect_path = '/' # When a user logs out.
|
239
251
|
```
|
@@ -20,7 +20,8 @@ module Passwordless
|
|
20
20
|
# renders sessions/create.html.erb.
|
21
21
|
# @see Mailer#magic_link Mailer#magic_link
|
22
22
|
def create
|
23
|
-
|
23
|
+
@resource = find_authenticatable
|
24
|
+
session = build_passwordless_session(@resource)
|
24
25
|
|
25
26
|
if session.save
|
26
27
|
if Passwordless.after_session_save.arity == 2
|
@@ -104,14 +105,12 @@ module Passwordless
|
|
104
105
|
end
|
105
106
|
|
106
107
|
def find_authenticatable
|
107
|
-
email = params[:passwordless][email_field].downcase
|
108
|
+
email = params[:passwordless][email_field].downcase.strip
|
108
109
|
|
109
110
|
if authenticatable_class.respond_to?(:fetch_resource_for_passwordless)
|
110
111
|
authenticatable_class.fetch_resource_for_passwordless(email)
|
111
112
|
else
|
112
|
-
authenticatable_class.where(
|
113
|
-
"lower(#{email_field}) = ?", params[:passwordless][email_field].downcase
|
114
|
-
).first
|
113
|
+
authenticatable_class.where("lower(#{email_field}) = ?", email).first
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Passwordless
|
4
4
|
# The mailer responsible for sending Passwordless' mails.
|
5
|
-
class Mailer <
|
5
|
+
class Mailer < Passwordless.parent_mailer.constantize
|
6
6
|
default from: Passwordless.default_from_address
|
7
7
|
|
8
8
|
# Sends a magic link (secret token) email.
|
@@ -11,7 +11,7 @@ module Passwordless
|
|
11
11
|
@session = session
|
12
12
|
|
13
13
|
@magic_link = send(Passwordless.mounted_as)
|
14
|
-
|
14
|
+
.token_sign_in_url(session.token)
|
15
15
|
|
16
16
|
email_field = @session.authenticatable.class.passwordless_email_field
|
17
17
|
mail(
|
data/lib/passwordless.rb
CHANGED
@@ -7,6 +7,7 @@ require "passwordless/url_safe_base_64_generator"
|
|
7
7
|
|
8
8
|
# The main Passwordless module
|
9
9
|
module Passwordless
|
10
|
+
mattr_accessor(:parent_mailer) { "ActionMailer::Base" }
|
10
11
|
mattr_accessor(:default_from_address) { "CHANGE_ME@example.com" }
|
11
12
|
mattr_accessor(:token_generator) { UrlSafeBase64Generator.new }
|
12
13
|
mattr_accessor(:restrict_token_reuse) { false }
|
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: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Malmberg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- mikkel@brnbw.com
|
86
86
|
executables: []
|
@@ -113,7 +113,7 @@ homepage: https://github.com/mikker/passwordless
|
|
113
113
|
licenses:
|
114
114
|
- MIT
|
115
115
|
metadata: {}
|
116
|
-
post_install_message:
|
116
|
+
post_install_message:
|
117
117
|
rdoc_options: []
|
118
118
|
require_paths:
|
119
119
|
- lib
|
@@ -128,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
-
signing_key:
|
131
|
+
rubygems_version: 3.1.4
|
132
|
+
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Add authentication to your app without all the ickyness of passwords.
|
135
135
|
test_files: []
|