passwordless 0.9.0 → 0.10.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: 906aa2b5a4bf5184d18d837c68565897bbeaa110550e875f44aaa71c8fee4c01
4
- data.tar.gz: b0155e0411c6f1ffca21b22f5f38da4f656c61770280bb3f0afa9ba9d1f6f737
3
+ metadata.gz: c45a41b4be30c959c37b50ef8013f4055c97ae516e4b8297b4f56607836cc09b
4
+ data.tar.gz: 7b0c50e087c5be36e5e89476764a407767aee4851fcb38c0b744bd532be8e982
5
5
  SHA512:
6
- metadata.gz: 19718426b946b054f327c13c00570a3ded2aba29d06f8b70cd446185ca2b92f969aee23faab8bda77a9f66f54aae6b7b493193d18f696ceaca427ec624b8d51c
7
- data.tar.gz: 95dbb1810540c40de5e1a828d61477f0786698e79ea47a5c65b5efba23108791aefa9c2a747550b8e46e56256f0281ad61d1b34ceb06f13f28d8063affde4469
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. It is recommended to set these in `initializers/passwordless.rb`. The default values are shown below.
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.token_generator = UrlSafeBase64Generator.new # Used to generate magic link tokens.
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 magic link expires.
233
- Passwordless.timeout_at = lambda { 1.hour.from_now } # How long until a passwordless session expires.
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
- session = build_passwordless_session(find_authenticatable)
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 < ActionMailer::Base
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
- .token_sign_in_url(session.token)
14
+ .token_sign_in_url(session.token)
15
15
 
16
16
  email_field = @session.authenticatable.class.passwordless_email_field
17
17
  mail(
@@ -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 }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passwordless
4
- VERSION = "0.9.0" # :nodoc:
4
+ VERSION = "0.10.0" # :nodoc:
5
5
  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: 0.9.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: 2019-12-19 00:00:00.000000000 Z
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.0.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: []