Files
fizzy/app/views/sessions/magic_links/show.html.erb
T
Kevin McConnell cdc1f9b143 Allow typing magic links on mobile
When typing a magic link, rather than pasting it, iOS seems to send
`keydown.enter`, and we weren't submitting the form in that case.

Changed to submit the form in either case, and use the state of the
input target to help guard against double submissions.
2025-12-02 20:09:26 +00:00

28 lines
1.3 KiB
Plaintext

<% @page_title = "Check your email" %>
<div class="panel panel--centered flex flex-column gap-half <%= "shake" if flash[:alert] %>">
<header>
<h1 class="txt-x-large font-weight-black margin-none"><%= @page_title %></h1>
<p class="margin-none-block-start txt-medium">Then enter the verification code included in the email below:</p>
</header>
<%= form_with url: session_magic_link_path, method: :post, html: { data: { controller: "magic-link" } } do |form| %>
<%= form.text_field :code, required: true, class: "input center txt-align-enter txt-large",
autofocus: true, autocorrect: "off", autocapitalize: "off", spellcheck: "false", "data-1p-ignore": true,
autocomplete: "one-time-code", maxlength: "6", placeholder: "••••••", value: params[:code],
data: { magic_link_target: "input", action: "keydown.enter->magic-link#submit paste->magic-link#submit" } %>
<% end %>
<p class="txt-small">The code you receive will work for <%= distance_of_time_in_words(MagicLink::EXPIRATION_TIME) %>.</p>
</div>
<% if Rails.env.development? %>
<script>
console.log("Magic link code: <%= flash[:magic_link_code].presence || "not generated" %>");
</script>
<% end %>
<% content_for :footer do %>
<%= render "sessions/footer" %>
<% end %>