door_check 0.6.0 → 0.7.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: a3a5a738229134d0abb0ed553d57e9f5789fb14f61175ea58e8bb31f483cc730
4
- data.tar.gz: a7ffe6b0a5f9b72740cd6e0bf9920c2ae8f1465865efe1025cd53809fbb4b661
3
+ metadata.gz: 968f243153c73db8d900939c954a2f608d26a46f2c38f014d62b16b9e53fdb90
4
+ data.tar.gz: e635c248345ae86aa2603af18c8dec88ff0c660e8867a308f6c03c0ceb8b263d
5
5
  SHA512:
6
- metadata.gz: d75faad89cdc9b99db58761ae5a976c0a00ad879efcc39d88ce9e09d990cf5a981edba9e70fadb6919c8da830a23a92063676dcbb604e88165d2ece89a9c581c
7
- data.tar.gz: d9d820d8369fd04dff81648fbd510bb4749925cbb8b5e51f4ec786b159112f44f8440fbed9d86e7efeb82ecb51c0d8604291123ad66a527e38332cbd154c9b35
6
+ metadata.gz: 94c04228dd18a038c8cdf7c614f1f14f5c53e0dc7fce1bcda7df737e04a726ad762f6919c1a83e1b24986ac68afaa4084db8b02485d6650bd04c4a2e82f455f8
7
+ data.tar.gz: 8fa4877e1a6c35e4322d4c9d7ea0b63228d7d008c329153772f4d133b303cf51ce54ee17d144a17499f9e43878c28caffe5df59270a96b50494fb1e319918f06
@@ -1,5 +1,8 @@
1
1
  module DoorCheck
2
2
  class EmailConfirmationsController < ApplicationController
3
+ rate_limit to: 5, within: 1.hour, only: :create, by: :resend_limit_key,
4
+ with: -> { render :limited, status: :too_many_requests }
5
+
3
6
  def show
4
7
  challenge = Challenge.redeem_token(params[:token], purpose: "confirm")
5
8
  return render(:expired, status: :not_found) unless challenge
@@ -17,11 +20,16 @@ module DoorCheck
17
20
 
18
21
  private
19
22
 
20
- def resend_target
21
- earlier = Challenge.for_token(params[:token].to_s, purpose: "confirm") if params[:token]
22
- return [ earlier.person, earlier.email ] if earlier
23
+ def resend_limit_key
24
+ person, = resend_target
25
+ person ? person.to_global_id.to_s : request.remote_ip
26
+ end
23
27
 
24
- [ door_check_person, EmailConfirmation.for(door_check_person).current_address ]
28
+ def resend_target
29
+ @resend_target ||= begin
30
+ earlier = Challenge.for_token(params[:token].to_s, purpose: "confirm") if params[:token]
31
+ earlier ? [ earlier.person, earlier.email ] : [ door_check_person, EmailConfirmation.for(door_check_person).current_address ]
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -36,9 +36,8 @@ module DoorCheck
36
36
  end
37
37
 
38
38
  def sign_in_method_tabs
39
- sign_in_methods.map do |method_name|
40
- { label: SIGN_IN_METHOD_LABELS.fetch(method_name), href: door_check.new_sign_up_path(request.query_parameters.merge(sign_in_method: method_name)),
41
- current: method_name == chosen_sign_in_method }
39
+ [ chosen_sign_in_method, *(sign_in_methods - [ chosen_sign_in_method ]) ].map do |method_name|
40
+ { method_name: method_name, label: SIGN_IN_METHOD_LABELS.fetch(method_name) }
42
41
  end
43
42
  end
44
43
 
@@ -8,7 +8,7 @@ module DoorCheck
8
8
 
9
9
  def self.confirmed?(person, email) = self.for(person).confirms?(email)
10
10
 
11
- def awaiting? = email.present? && !confirms?(current_address)
11
+ def awaiting? = email.present? && current_address.present? && !confirms?(current_address)
12
12
 
13
13
  def confirms?(address) = confirmed_at.present? && email.to_s.casecmp?(address.to_s.strip)
14
14
 
@@ -0,0 +1,5 @@
1
+ <%= ui_page(max_width: :md) do %>
2
+ <%= ui_section(title: "Confirm your email address") do %>
3
+ <%= ui_alert(message: "You asked for the confirmation email too many times. Try again later.", type: :error) %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= hidden_field_tag "sign_in_method", method_name.to_s, id: nil %>
2
+ <% if method_name == :password %>
3
+ <%= ui_form_field(attribute: "password", label: "Password", type: :password, required: true, autocomplete: "new-password") %>
4
+ <% else %>
5
+ <%= ui_paragraph(text: "We will send you a code and a link.") %>
6
+ <% end %>
@@ -1,18 +1,29 @@
1
1
  <%= ui_page(max_width: :md) do %>
2
- <%= ui_section(title: "Sign up", subtitle: chosen_sign_in_method == :password ? "Enter your name and email address and choose a password." : "Enter your name and email address and we will send you a code and a link.") do %>
3
- <%= ui_tab_switcher(tabs: sign_in_method_tabs) if sign_in_method_tabs.many? %>
2
+ <%= ui_section(title: "Sign up", subtitle: "Enter your name and email address.") do %>
4
3
  <%= ui_alert(message: @error, type: :error) if @error %>
5
4
  <%= ui_form(action: door_check.sign_up_path(request.query_parameters)) do %>
6
- <%= ui_form_field(attribute: "name", label: "Name", value: params[:name], required: true, autofocus: true, autocomplete: "name") %>
7
- <%= ui_form_field(attribute: "email", label: "Email", type: :email, value: params[:email], required: true,
8
- autocomplete: "email", autocapitalize: "none") %>
9
- <% if chosen_sign_in_method == :password %>
10
- <%= ui_form_field(attribute: "password", label: "Password", type: :password, required: true, autocomplete: "new-password") %>
5
+ <% identity_fields = capture do %>
6
+ <%= ui_form_field(attribute: "name", label: "Name", value: params[:name], required: true, autofocus: true, autocomplete: "name") %>
7
+ <%= ui_form_field(attribute: "email", label: "Email", type: :email, value: params[:email], required: true,
8
+ autocomplete: "email", autocapitalize: "none") %>
9
+ <% end %>
10
+ <% if sign_in_method_tabs.many? %>
11
+ <%= ui_tab_switcher(tabs: sign_in_method_tabs.map { |tab| tab[:label] }) do |switcher| %>
12
+ <%= identity_fields %>
13
+ <% sign_in_method_tabs.each do |tab| %>
14
+ <% switcher.with_panel do %>
15
+ <%= render "door_check/sign_ups/sign_in_method_fields", method_name: tab[:method_name] %>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ <% else %>
20
+ <%= identity_fields %>
21
+ <%= render "door_check/sign_ups/sign_in_method_fields", method_name: sign_in_method_tabs.first[:method_name] %>
11
22
  <% end %>
12
23
  <%= ui_form_field(attribute: "agreement", label: DoorCheck.configuration.sign_up_agreement_label, type: :checkbox, value: params[:agreement],
13
24
  required: true) %>
14
25
  <%= ui_link_list(rows: DoorCheck.configuration.sign_up_agreement_links.call(controller)
15
- .map { |document| { label: document.fetch(:title), href: document.fetch(:url) } }) %>
26
+ .map { |document| { label: document.fetch(:title), href: document.fetch(:url) } }, new_tab: true) %>
16
27
  <%= ui_button(label: "Sign up") %>
17
28
  <% end %>
18
29
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module DoorCheck
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -51,7 +51,7 @@ Paths, called on the engine's route proxy `door_check` from host views and
51
51
  controllers:
52
52
 
53
53
  - `door_check.new_email_sign_in_path` — the page where a person enters their email to be sent a sign-in code and a sign-in link.
54
- - `door_check.new_sign_up_path` — the page where a person with no login enters a name and an email to create one, then either is sent a sign-in code and a sign-in link or chooses a password, is signed in and is emailed a confirmation link. An address that already has an account is never signed up again: whatever the visitor chose, that person is emailed a sign-in code and link, the visitor is taken to the email code page, and nobody is signed in by password.
54
+ - `door_check.new_sign_up_path` — the page where a person with no login enters a name and an email, picks "Emailed code" or "Password" on the same page, ticks a required agreement checkbox, and signs up. On "Emailed code" they are sent a sign-in code and a sign-in link. On "Password" they enter a password, are signed in and are emailed a confirmation link. An address that already has an account is never signed up again: whatever the visitor chose, that person is emailed a sign-in code and link, the visitor is taken to the email code page, and nobody is signed in by password.
55
55
  - `door_check.new_passkey_sign_in_path` — the page where a person signs in with a passkey.
56
56
  - `door_check.new_approval_request_path` — the page where a person asks to be let in by approving from a device they are already signed in on.
57
57
  - `door_check.approvals_path` — the page where a signed-in person sees waiting approval requests and approves or declines them.
@@ -147,11 +147,22 @@ the address the host holds for them now.
147
147
  address is not confirmed or differs from the address `person.email` returns
148
148
  now, ignoring case and surrounding spaces. A person door_check has never
149
149
  stored an address for, such as one who existed before door_check kept
150
- confirmations, does not see it.
150
+ confirmations, does not see it. A person whose `email` is blank does not see
151
+ it either.
151
152
  - That button posts to door_check's own route, so the host writes no action
152
153
  for it. The new link goes to the address `person.email` returns now, or to
153
- the address door_check stored when the person does not answer `email`.
154
- Opening it confirms that address, so `confirmed?` returns true for it.
154
+ the address door_check stored when the person does not answer `email` at
155
+ all. Opening it confirms that address, so `confirmed?` returns true for it.
156
+ - door_check sends the confirmation email again at most five times in an hour
157
+ for each person. That button and the "Send a new confirmation email" button
158
+ on a used or expired confirmation link's page count toward the same limit. A
159
+ sixth request sends nothing and shows a page saying "You asked for the
160
+ confirmation email too many times. Try again later.". The host writes
161
+ nothing for this, and cannot change the number or the hour.
162
+ - The limit is counted in the host's Rails cache, which the install local sets
163
+ up. Under a cache that keeps nothing, such as development without
164
+ `bin/rails dev:cache`, no request is refused. Hand a question about the
165
+ cache to the install local.
155
166
  - Earlier confirmation links keep working until each is used or expires.
156
167
  Opening one sent to an older address confirms that older address, which
157
168
  leaves the button showing while the host holds a different one.
@@ -421,7 +432,7 @@ What happens when the "This wasn't me" link is opened:
421
432
  `sign_up_person` is set.
422
433
  Values added to the sign-up path, such as
423
434
  `door_check.new_sign_up_path(invitation: token)`, reach `sign_up_person`
424
- with the form's name and email. The approvals page and the
435
+ with the values the form sends. The approvals page and the
425
436
  authenticator page do not, so a link to either shown without its method
426
437
  offered leads to a working page for a method the app does not offer.
427
438
  3. The sign-in email always carries both a code and a link. The link returns
@@ -444,22 +455,29 @@ What happens when the "This wasn't me" link is opened:
444
455
  host that hides it can send people there through its own links, such as an
445
456
  invitation built with `door_check.new_sign_up_path(invitation: token)`.
446
457
  Ask the developer which of the host's pages should link to sign-up.
447
- 7. Link to `backup_codes_path` with a form that sends a `POST`, such as
458
+ 7. When the app offers both `email_code` and `password`, the sign-up page
459
+ opens on "Emailed code". A link built with
460
+ `door_check.new_sign_up_path(sign_in_method: "password")` opens it on
461
+ "Password" instead. The visitor can still switch to the other choice on the
462
+ page. Ask the developer which choice each sign-up link should open on.
463
+ When only one of the two is offered, the page shows only that one and
464
+ `sign_in_method` in the link changes nothing.
465
+ 8. Link to `backup_codes_path` with a form that sends a `POST`, such as
448
466
  `button_to`, never a plain link.
449
- 8. When the person already has a second step set up, the authenticator, passkey
467
+ 9. When the person already has a second step set up, the authenticator, passkey
450
468
  and backup codes pages first ask for it if this session has not passed one,
451
469
  then send the person back.
452
- 9. The authenticator page keeps showing the same secret key in this browser
453
- session until setup succeeds, so reloading it or entering a wrong code does
454
- not change the key the person already scanned. A wrong code shows an error on
455
- the same page and saves nothing.
456
- 10. When the browser session no longer holds the key, such as after the person
457
- signed out and back in, saving a code sends the person back to the
458
- authenticator page with a new key and a warning to scan it again.
459
- 11. A right code saves the authenticator app, counts as this session's second
460
- step, and sends the person to the page they were on before door_check asked
461
- for a second step, or to `/` when there was none. The app lists the account
462
- under the person's email when the person responds to `email`.
470
+ 10. The authenticator page keeps showing the same secret key in this browser
471
+ session until setup succeeds, so reloading it or entering a wrong code does
472
+ not change the key the person already scanned. A wrong code shows an error
473
+ on the same page and saves nothing.
474
+ 11. When the browser session no longer holds the key, such as after the person
475
+ signed out and back in, saving a code sends the person back to the
476
+ authenticator page with a new key and a warning to scan it again.
477
+ 12. A right code saves the authenticator app, counts as this session's second
478
+ step, and sends the person to the page they were on before door_check asked
479
+ for a second step, or to `/` when there was none. The app lists the account
480
+ under the person's email when the person responds to `email`.
463
481
 
464
482
  ## Conventions
465
483
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: door_check-info
3
- description: Use to learn what door_check offers — the sign-in methods and second steps an app offers, the rules an account or a person sets on them, the sessions and trusted browsers a person can see and end, the sign-up page with its sign-in choice and agreement checkbox, email address confirmation with its confirmation email and resend button, a request to change a person's email address with the link that confirms it and the notice to the current address whose link cancels it, and the vocabulary the install and develop locals assume.
3
+ description: Use to learn what door_check offers — the sign-in methods and second steps an app offers, the rules an account or a person sets on them, the sessions and trusted browsers a person can see and end, the sign-up page with its sign-in choice and agreement checkbox, email address confirmation with its confirmation email, resend button and resend limit, a request to change a person's email address with the link that confirms it and the notice to the current address whose link cancels it, and the vocabulary the install and develop locals assume.
4
4
  tools: Read
5
5
  scope: sign-in — the sign-in methods and second steps an app offers, each account narrows, and each person chooses from
6
6
  ---
@@ -86,10 +86,12 @@ door_check declares nothing for this local to document.
86
86
  and nothing is sent. An error the callable raised is reported to
87
87
  `Rails.error`.
88
88
  - **Sign-in choice at sign-up** — when the app offers both email codes and
89
- passwords, the sign-up page shows a tab for each and opens on the emailed
90
- code. When it offers one, only that one shows. The callable receives the
91
- choice as `sign_in_method`, `"password"` or `"email_code"`, which may be
92
- missing when the person kept the first choice.
89
+ passwords, the sign-up page shows two tabs, "Emailed code" and "Password",
90
+ and opens on "Emailed code". Switching tabs does not reload the page, and the
91
+ name and email already typed stay filled in. A refused sign-up reopens the
92
+ page on the tab the person chose. When the app offers one of the two, the
93
+ page shows no tabs and only that choice. The callable receives the choice on
94
+ every sign-up as `sign_in_method`, `"password"` or `"email_code"`.
93
95
  - **Email code sign-up** — on ok, door_check emails a sign-in code and link and
94
96
  takes the person to the email code page, and entering the code signs them in
95
97
  by email code.
@@ -130,9 +132,16 @@ door_check declares nothing for this local to document.
130
132
  never confirmed, and a confirmed person whose host address has since
131
133
  changed. The button sends a new link to the address the host holds now, and
132
134
  opening it confirms that address. A person door_check has no address on
133
- record for sees no button. The earlier link keeps working until it expires.
134
- The "Send a new confirmation email" button on a used or expired link's page
135
- still sends to the address that link was for.
135
+ record for, or whose host address is blank, sees no button. The earlier link
136
+ keeps working until it expires. The "Send a new confirmation email" button on
137
+ a used or expired link's page still sends to the address that link was for.
138
+ - **Resend limit** — a person can ask for the confirmation email five times in
139
+ an hour. Both the resend button and the "Send a new confirmation email"
140
+ button count toward the same person's five. A sixth request in that hour
141
+ sends nothing and shows a page saying "You asked for the confirmation email
142
+ too many times. Try again later." A request with no person behind it is
143
+ counted by IP address instead. The count is kept in the app's cache, so an
144
+ app whose cache stores nothing never refuses a request.
136
145
  - **Email change request** — the host asks door_check to change a person's
137
146
  email address to a new one. door_check emails the new address one link, with
138
147
  the subject "Confirm your new email address". The link works once and for 24
@@ -179,7 +188,8 @@ door_check declares nothing for this local to document.
179
188
  - **Sign-up agreement** — the required checkbox on the sign-up page. Its label
180
189
  is "I agree to the Terms of Service and Privacy Policy" unless the host sets
181
190
  another, and the host may list documents, each a title and an address, shown
182
- as links under it. When it is not ticked, the page refuses the sign-up with
191
+ as links under it. Each link opens in a new tab, so the sign-up page stays
192
+ open. When it is not ticked, the page refuses the sign-up with
183
193
  "Tick the agreement to sign up.", keeps the name and email, and does not call
184
194
  the host's sign-up callable. When it is ticked, the callable receives
185
195
  `agreement` as `"1"` with the other values, and the host's own terms and
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: door_check-install
3
- description: Use to hook door_check into a project — adding the gem, copying its migrations, mounting its routes, configuring the offered methods and the host's person, account, sign-in and sign-out hooks, the parent controller and mailer, the passkey domain, the IP lookup, the stylesheet and head partial, the name shown in authenticator apps, whether people may choose their own second step, the callable that creates a person from the sign-up page, the sign-up page's agreement label and the documents linked under it, whether the email sign-in page links to the sign-up page, the callable that saves a person's new email address once they open the link that confirms it, the callable told when a person cancels an email change from the notice sent to their current address, the confirmation email sent after a password sign-up and what the app holds back from a person whose address is not confirmed, adding the sign-in tracking and second-step check to the host's controller, and placing the two settings sections.
3
+ description: Use to hook door_check into a project — adding the gem, copying its migrations, mounting its routes, setting up the cache that counts confirmation email requests, configuring the offered methods and the host's person, account, sign-in and sign-out hooks, the parent controller and mailer, the passkey domain, the IP lookup, the stylesheet and head partial, the name shown in authenticator apps, whether people may choose their own second step, the callable that creates a person from the sign-up page, the sign-up page's agreement label and the documents linked under it, whether the email sign-in page links to the sign-up page, the callable that saves a person's new email address once they open the link that confirms it, the callable told when a person cancels an email change from the notice sent to their current address, the confirmation email sent after a password sign-up and what the app holds back from a person whose address is not confirmed, adding the sign-in tracking and second-step check to the host's controller, and placing the two settings sections.
4
4
  tools: Bash, Read, Edit
5
5
  scope: sign-in — the sign-in methods and second steps an app offers, each account narrows, and each person chooses from
6
6
  ---
@@ -58,9 +58,11 @@ trusted browsers.
58
58
  ```
59
59
  bundle install
60
60
  ```
61
- door_check's pages are built with keystone_ui. If the host does not already
62
- have keystone_ui installed, hand that to the keystone_ui install local before
63
- going on.
61
+ door_check's pages are built with keystone_ui 0.100.0 or later. If the host
62
+ does not already have keystone_ui installed, hand that to the keystone_ui
63
+ install local before going on. If the host's `Gemfile` holds keystone_ui
64
+ below 0.100.0, `bundle install` fails, so ask the developer before raising
65
+ that version.
64
66
 
65
67
  2. Copy and run the migrations:
66
68
  ```
@@ -95,7 +97,21 @@ trusted browsers.
95
97
  sent to the current address about that change each carry a link built
96
98
  from it.
97
99
 
98
- 6. Create `config/initializers/door_check.rb`:
100
+ 6. Check `config.cache_store` in each `config/environments/*.rb`. door_check
101
+ lets a person ask for the confirmation email five times in an hour, and
102
+ counts those requests in the host's Rails cache.
103
+ - Under `:null_store` nothing is counted, so no request is ever refused.
104
+ Rails sets `:null_store` in development unless caching is turned on with
105
+ `bin/rails dev:cache`.
106
+ - Under `:memory_store` each server process keeps its own count, so a host
107
+ running several processes lets a person ask more than five times.
108
+ - A store shared by every process, such as `:solid_cache_store`,
109
+ `:redis_cache_store` or `:mem_cache_store`, applies the limit as stated.
110
+
111
+ Ask the developer which store production uses when it is not a shared one.
112
+ door_check adds no cache setting of its own.
113
+
114
+ 7. Create `config/initializers/door_check.rb`:
99
115
  ```ruby
100
116
  DoorCheck.configure do |config|
101
117
  config.offered_methods = %i[password email_code email_link device_approval passkey authenticator_app backup_codes trusted_device]
@@ -126,7 +142,7 @@ trusted browsers.
126
142
  - **`find_person_by_email`** is required when `email_code`, `email_link` or
127
143
  `device_approval` is offered.
128
144
 
129
- 7. Add the optional settings only when the developer wants them:
145
+ 8. Add the optional settings only when the developer wants them:
130
146
  - `config.existing_authenticator = "StoredAuthenticator"` — when the host
131
147
  already has an authenticator app or backup codes of its own. The class is
132
148
  built with no arguments and must answer `set_up?(person)`, true when the
@@ -218,12 +234,14 @@ trusted browsers.
218
234
  - It answers not found unless `sign_up_person` is set and
219
235
  `offered_methods` includes `password`, `email_code`, or both.
220
236
  - When both are offered, the page shows two tabs, "Emailed code" and
221
- "Password", and opens on "Emailed code". When only one is offered,
222
- only that one shows, with no tabs.
223
- - `values[:sign_in_method]` carries the visitor's choice, `"password"` or
224
- `"email_code"`. It may be missing when the visitor kept the page's
225
- first choice, which is `email_code` when it is offered and `password`
226
- otherwise.
237
+ "Password", and opens on "Emailed code". Switching tabs does not
238
+ reload the page, and the name and email already typed stay filled in.
239
+ When only one is offered, only that one shows, with no tabs.
240
+ - A link to the page with `sign_in_method=password` in its address opens
241
+ it on the "Password" tab. A refused sign-up reopens the page on the
242
+ tab the visitor chose.
243
+ - `values[:sign_in_method]` carries the visitor's choice on every
244
+ sign-up, `"password"` or `"email_code"`.
227
245
  - On the password choice the page also asks for a password, and `values`
228
246
  carries it as typed in `values[:password]`. The host saves the
229
247
  password. door_check never stores it.
@@ -245,6 +263,12 @@ trusted browsers.
245
263
  cannot sign anyone in, and a sign-in link cannot confirm an address.
246
264
  A used or expired link shows a page with a "Send a new confirmation
247
265
  email" button, which sends a new link to the same address.
266
+ - That button and the settings section's "Send the confirmation email
267
+ again" button count toward the same limit of five requests per person
268
+ in an hour, kept in the cache step 6 checks. A sixth request sends
269
+ nothing and shows a page saying "You asked for the confirmation email
270
+ too many times. Try again later.". A request with no person behind it
271
+ is counted by IP address.
248
272
  - When the confirmation email fails to send, door_check reports the
249
273
  error to `Rails.error`. The person stays signed in, and the personal
250
274
  settings section still offers to send the confirmation email again.
@@ -283,6 +307,7 @@ trusted browsers.
283
307
  ```
284
308
  The titles and routes are examples. Ask the developer which documents to
285
309
  link and where each one is. Each hash must carry both `title` and `url`.
310
+ Each link opens in a new tab, so the sign-up page stays open.
286
311
  - `config.sign_up_link_on_sign_in = false` — defaults to true. While it is
287
312
  true and the sign-up page is on, the email sign-in page shows a "Create an
288
313
  account" button under its form that opens the sign-up page. Set it to
@@ -365,7 +390,7 @@ trusted browsers.
365
390
  works shows a page titled "Email change not cancelled", and the
366
391
  lambda is not called.
367
392
 
368
- 8. Ask the developer what the app should hold back from a person whose email
393
+ 9. Ask the developer what the app should hold back from a person whose email
369
394
  address is not confirmed, such as sending invitations or changing billing.
370
395
  door_check holds nothing back on its own. The host decides, by asking
371
396
  door_check whether the person's current address is confirmed:
@@ -378,27 +403,27 @@ trusted browsers.
378
403
  develop local's work, so hand the answers to it. When the developer wants
379
404
  nothing held back, skip this step.
380
405
 
381
- 9. Add the tracking and the second-step check to the host's
382
- `app/controllers/application_controller.rb`, or to the controller named in
383
- `parent_controller`:
384
- ```ruby
385
- class ApplicationController < ActionController::Base
386
- include DoorCheck::Tracking
387
- include DoorCheck::EntryCheck
406
+ 10. Add the tracking and the second-step check to the host's
407
+ `app/controllers/application_controller.rb`, or to the controller named in
408
+ `parent_controller`:
409
+ ```ruby
410
+ class ApplicationController < ActionController::Base
411
+ include DoorCheck::Tracking
412
+ include DoorCheck::EntryCheck
388
413
 
389
- before_action :door_check_check_entry
390
- end
391
- ```
392
- door_check's own pages skip the check. Ask the developer whether any host
393
- controller, such as the sign-in page, should also skip it with
394
- `skip_before_action :door_check_check_entry`. A request with no signed-in
395
- person always passes the check.
414
+ before_action :door_check_check_entry
415
+ end
416
+ ```
417
+ door_check's own pages skip the check. Ask the developer whether any host
418
+ controller, such as the sign-in page, should also skip it with
419
+ `skip_before_action :door_check_check_entry`. A request with no signed-in
420
+ person always passes the check.
396
421
 
397
- 10. Record each sign-in made by the host's own sign-in page. That call is the
422
+ 11. Record each sign-in made by the host's own sign-in page. That call is the
398
423
  develop local's to write. Hand it to the develop local before the app goes
399
424
  live, since a session that was never recorded meets no second-step rule.
400
425
 
401
- 11. Place the two settings sections on the host's settings pages:
426
+ 12. Place the two settings sections on the host's settings pages:
402
427
  ```erb
403
428
  <%= render "door_check/settings/sign_in_methods",
404
429
  person: current_user,
@@ -438,11 +463,14 @@ trusted browsers.
438
463
  email again" button when door_check holds an address for the person and
439
464
  the address the person answers `email` with is not confirmed. That
440
465
  covers an address never confirmed and one the host changed after it was
441
- confirmed. That button posts to door_check's own route, so the host adds
442
- no route for it. It sends a new link to the address the person answers
443
- `email` with now, or to the address door_check stored at sign-up when
444
- the person has no `email`. Opening that link confirms the address it was
445
- sent to. An earlier link keeps working until it expires.
466
+ confirmed. A person whose `email` is blank sees no button. That button
467
+ posts to door_check's own route, so the host adds no route for it. It
468
+ sends a new link to the address the person answers `email` with now, or
469
+ to the address door_check stored at sign-up when the person does not
470
+ answer `email` at all. Opening that link confirms the address it was
471
+ sent to. An earlier link keeps working until it expires. A sixth press
472
+ within an hour sends nothing and shows the "Try again later." page
473
+ described under `sign_up_person`.
446
474
  - **Signed-in sessions** — the person's sessions that are still signed in.
447
475
  - **Trusted browsers** — shown only when `trusted_device` is offered.
448
476
  - **Second step** — the person's own second-step checkbox, or a note in its
@@ -493,6 +521,8 @@ trusted browsers.
493
521
  needs adding to the host's `config/importmap.rb`.
494
522
  - After upgrading the gem, run `bin/rails door_check:install:migrations` and
495
523
  `bin/rails db:migrate` again to copy any new migrations.
524
+ - After upgrading to a door_check with the confirmation email limit, run step 6
525
+ again for each environment.
496
526
  - Changing `offered_methods` needs an app restart.
497
527
  - Out of scope: recording a sign-in, reading proofs, checking whether a
498
528
  person's address is confirmed, requesting a change of a person's email
@@ -93,7 +93,9 @@ sources:
93
93
  - app/views/door_check/settings/_sign_in_methods.html.erb
94
94
  - app/views/door_check/settings/_sign_in_rules.html.erb
95
95
  - app/views/door_check/sign_ups/new.html.erb
96
+ - app/views/door_check/sign_ups/_sign_in_method_fields.html.erb
96
97
  - app/views/door_check/email_sign_ins/new.html.erb
98
+ - app/views/door_check/email_confirmations/limited.html.erb
97
99
  - app/views/door_check/email_changes/show.html.erb
98
100
  - app/views/door_check/email_changes/refused.html.erb
99
101
  - app/views/door_check/email_changes/expired.html.erb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: door_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0.50'
32
+ version: 0.100.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0.50'
39
+ version: 0.100.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rotp
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +163,7 @@ files:
163
163
  - app/views/door_check/email_changes/show.html.erb
164
164
  - app/views/door_check/email_codes/new.html.erb
165
165
  - app/views/door_check/email_confirmations/expired.html.erb
166
+ - app/views/door_check/email_confirmations/limited.html.erb
166
167
  - app/views/door_check/email_confirmations/sent.html.erb
167
168
  - app/views/door_check/email_confirmations/show.html.erb
168
169
  - app/views/door_check/email_links/expired.html.erb
@@ -180,6 +181,7 @@ files:
180
181
  - app/views/door_check/sign_in_mailer/email_change_confirmation.text.erb
181
182
  - app/views/door_check/sign_in_mailer/email_change_notice.html.erb
182
183
  - app/views/door_check/sign_in_mailer/email_change_notice.text.erb
184
+ - app/views/door_check/sign_ups/_sign_in_method_fields.html.erb
183
185
  - app/views/door_check/sign_ups/new.html.erb
184
186
  - app/views/layouts/door_check/application.html.erb
185
187
  - config/importmap.rb