mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- 10 failed sign-ins in a row (password, authenticator code, or password at signing) lock an account for 15 minutes from any address; the user is emailed; admins can unlock. Same message as a wrong password. - Passwords: at least 12 characters (max 72), refused if found in Have I Been Pwned (k-anonymity range API; fails open; PWNED_PASSWORDS_CHECK=false) - Optional TOTP (authenticator app) with 10 recovery codes for password and emailed-link sign-in, and at signing (auth method password_totp); codes accepted once; admins can reset; SSO sign-in unaffected - Demo/test passwords updated; guide, README and procedures document Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
4.1 KiB
ERB
58 lines
4.1 KiB
ERB
<%# Signing form: review, certificate, re-authentication, confirm. Locals: entry, url, cancel_path. %>
|
|
<section class="card max-w-3xl">
|
|
<div class="card-header"><h2 class="card-title">Sign this entry</h2></div>
|
|
<div class="card-body space-y-4">
|
|
<p class="text-sm text-slate-600">Review the entry: your signature will cover exactly what's shown here, and it can't be changed afterwards. A mistake is fixed with a correction entry. <%= link_to "How signing works", records_help_path, class: "link", target: "_blank" %></p>
|
|
<%= render "logbook_entries/content", entry: entry %>
|
|
<% if @signing_error %>
|
|
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><%= @signing_error %></div>
|
|
<% end %>
|
|
<% if @certificates.empty? %>
|
|
<p class="rounded-md bg-amber-50 p-3 text-sm text-amber-900 ring-1 ring-amber-200">
|
|
To sign, add your certificate on <%= link_to "your profile", edit_profile_path(anchor: "certificates"), class: "link" %>.
|
|
</p>
|
|
<% else %>
|
|
<%= form_with url: url, method: :post, class: "space-y-4" do %>
|
|
<fieldset class="space-y-2">
|
|
<legend class="label">Sign with</legend>
|
|
<% @certificates.each_with_index do |c, i| %>
|
|
<% problems = entry.signing_problems(c) %>
|
|
<label class="flex items-start gap-2 rounded-md p-2 text-sm ring-1 ring-slate-200 <%= 'opacity-60' if problems.any? %>">
|
|
<%= radio_button_tag :certificate_id, c.id, params[:certificate_id].to_s == c.id.to_s || (params[:certificate_id].blank? && i.zero? && problems.empty?),
|
|
disabled: problems.any?, class: "mt-1" %>
|
|
<span><strong><%= current_user.display_name %>, <%= c.kind_label %> <%= c.number %></strong>
|
|
<% if problems.any? %><span class="block text-xs text-red-700">Can't sign: <%= problems.to_sentence %>.</span>
|
|
<% else %><span class="block text-slate-600"><%= EntrySignature::LABEL %>: “<%= entry.certification_statement(c.kind) %>”</span><% end %></span>
|
|
</label>
|
|
<% end %>
|
|
</fieldset>
|
|
<% if Sso.password_login? || !current_user.sso_uid? %>
|
|
<div class="max-w-xs">
|
|
<%= label_tag :password, "Your password", class: "label" %>
|
|
<%= password_field_tag :password, nil, class: "input", autocomplete: "current-password" %>
|
|
<p class="hint">Proves it's you signing, not someone at your keyboard.<%= " Or sign in again with #{Sso.label} below." if Sso.enabled? && current_user.sso_uid? %></p>
|
|
</div>
|
|
<% if current_user.otp_enabled? %>
|
|
<div class="max-w-xs">
|
|
<%= label_tag :otp_code, "Authenticator code", class: "label" %>
|
|
<%= text_field_tag :otp_code, nil, class: "input w-32 tracking-widest", autocomplete: "one-time-code", inputmode: "numeric", maxlength: 20 %>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
<% if Sso.enabled? && current_user.sso_uid? %>
|
|
<% fresh = session[:reauthenticated_at] && Time.zone.at(session[:reauthenticated_at]) > EntrySigner::REAUTH_WINDOW.ago %>
|
|
<p class="text-sm <%= fresh ? 'text-emerald-700' : 'text-slate-600' %>"><%= fresh ? "Signed in again with #{Sso.label}: you can sign now." : "Or sign in again with #{Sso.label} first (button below the form)." %></p>
|
|
<% end %>
|
|
<label class="flex items-start gap-2 text-sm">
|
|
<%= check_box_tag :confirm, "1", false, class: "mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300" %>
|
|
<span>I am signing this entry myself, with the intent to sign it, and certify the statement above.</span>
|
|
</label>
|
|
<div class="flex gap-2"><%= submit_tag "Sign entry", class: "btn-primary" %><%= link_to "Cancel", cancel_path, class: "btn-secondary" %></div>
|
|
<% end %>
|
|
<% if Sso.enabled? && current_user.sso_uid? %>
|
|
<%= button_to "Sign in again with #{Sso.label}", "/auth/#{Sso::PROVIDER}", params: { prompt: "login" }, class: "btn-secondary btn-sm", data: { turbo: false } %>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
</section>
|