mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
110 lines
7.8 KiB
ERB
110 lines
7.8 KiB
ERB
<h1 class="mb-4 text-2xl font-bold">Your Profile</h1>
|
|
<%= form_with model: @user, url: profile_path, method: :patch, class: "card card-body space-y-4 max-w-md" do |f| %>
|
|
<%= f.errors_summary %>
|
|
<%= f.field :name %>
|
|
<%= f.field :email_address, as: :email, label: "Email" %>
|
|
<%= f.field :reminder_emails, as: :checkbox, label: "Weekly maintenance reminders",
|
|
hint: "A Monday email about overdue and upcoming inspections, ADs, parts and documents on aircraft you own, and certificates of yours about to expire. Only sent when something needs attention#{' (once email is set up)' unless MailSettings.configured?}." %>
|
|
<%= f.field :password, as: :password, label: "New password", hint: "Leave blank to keep your current password. At least #{User::PASSWORD_MIN} characters; not one known from a data breach.", autocomplete: "new-password" %>
|
|
<%= f.field :password_confirmation, as: :password, label: "Confirm new password", autocomplete: "new-password" %>
|
|
<div>
|
|
<%= label_tag "user[current_password]", "Current password", class: "label" %>
|
|
<%= password_field_tag "user[current_password]", nil, id: "user_current_password", class: "input", autocomplete: "current-password" %>
|
|
<p class="hint">Needed to change your email or password.<%= " Signed up with #{Sso.label} and never set one? Use “Forgot password?” on the sign-in page." if Sso.enabled? && @user.sso_uid? %></p>
|
|
</div>
|
|
<%= f.submit "Save" %>
|
|
<% end %>
|
|
|
|
<% if Sso.enabled? %>
|
|
<section class="card card-body mt-5 max-w-md">
|
|
<h2 class="card-title">Single sign-on</h2>
|
|
<% if @user.sso_uid? %>
|
|
<p class="mt-1 text-sm text-slate-600">Your account is linked to <%= Sso.label %>; you can sign in with it.</p>
|
|
<% if Sso.password_login? %>
|
|
<div class="mt-3"><%= button_to "Unlink #{Sso.label}", sso_link_path, method: :delete, class: "btn-secondary btn-sm",
|
|
form: { data: { turbo_confirm: "Unlink #{Sso.label}? You'll sign in with your email and password." } } %></div>
|
|
<% end %>
|
|
<% else %>
|
|
<p class="mt-1 text-sm text-slate-600">Link your <%= Sso.label %> account to sign in with it.</p>
|
|
<div class="mt-3"><%= button_to "Link #{Sso.label}", "/auth/#{Sso::PROVIDER}", class: "btn-secondary btn-sm", data: { turbo: false } %></div>
|
|
<% end %>
|
|
</section>
|
|
<% end %>
|
|
|
|
<section class="card card-body mt-5 max-w-md" id="two-factor">
|
|
<h2 class="card-title">Two-factor sign-in</h2>
|
|
<% if @user.otp_enabled? %>
|
|
<p class="mt-1 text-sm text-slate-600"><span class="badge-green">On</span> since <%= fmt_date(@user.otp_enabled_at.to_date) %>: signing in with your password or an emailed link also asks for a code from your authenticator app. <%= @user.recovery_codes_left %> recovery codes left.</p>
|
|
<%= form_with url: two_factor_path, class: "mt-3 flex flex-wrap items-end gap-2" do |f| %>
|
|
<div><%= label_tag :code, "Current code or a recovery code", class: "label" %><%= text_field_tag :code, nil, required: true, autocomplete: "one-time-code", class: "input w-44" %></div>
|
|
<%= button_tag "New recovery codes", type: "submit", formaction: recovery_codes_two_factor_path, class: "btn-secondary btn-sm" %>
|
|
<%= button_tag "Turn off", type: "submit", name: "_method", value: "delete", class: "btn-secondary btn-sm", data: { turbo_confirm: "Turn off two-factor sign-in?" } %>
|
|
<% end %>
|
|
<% else %>
|
|
<p class="mt-1 text-sm text-slate-600">Add a code from an authenticator app on your phone to password and emailed-link sign-in, so a stolen password alone can't get in.<%= " (Signing in with #{Sso.label} uses its own second factor.)" if Sso.enabled? %></p>
|
|
<div class="mt-3"><%= link_to "Set up", new_two_factor_path, class: "btn-secondary btn-sm" %></div>
|
|
<% end %>
|
|
</section>
|
|
|
|
<section class="card card-body mt-5 max-w-md" id="calendar">
|
|
<h2 class="card-title">Calendar feed</h2>
|
|
<p class="mt-1 text-sm text-slate-600">What's coming due on your aircraft (inspections, ADs, part replacements and limits, expiring documents) in your calendar app. Items due by hours get a date projected from the past year's flying; it updates on its own.</p>
|
|
<% if @user.calendar_token.present? %>
|
|
<% feed = "#{Sso.app_url}#{calendar_feed_path(@user.calendar_token)}" %>
|
|
<input class="input mt-3 font-mono text-xs" value="<%= feed %>" readonly aria-label="Calendar feed address">
|
|
<div class="mt-2 flex flex-wrap gap-2">
|
|
<%= link_to "Subscribe", feed.sub(%r{\Ahttps?://}, "webcal://"), class: "btn-secondary btn-sm" %>
|
|
<%= button_to "Make a new link", calendar_token_path, class: "btn-secondary btn-sm",
|
|
form: { data: { turbo_confirm: "Replace the calendar link? Calendars using the old one stop updating." } } %>
|
|
</div>
|
|
<p class="hint">Anyone with this link can see the due list, so keep it private. In Google Calendar: Other calendars → From URL. On an iPhone: tap Subscribe.</p>
|
|
<% else %>
|
|
<div class="mt-3"><%= button_to "Create calendar link", calendar_token_path, class: "btn-secondary btn-sm" %></div>
|
|
<% end %>
|
|
</section>
|
|
|
|
<section class="card card-body mt-5 max-w-md" id="certificates">
|
|
<h2 class="card-title">Certificates</h2>
|
|
<p class="mt-1 text-sm text-slate-600">Your FAA certificates, for signing logbook entries: “Sign as” fills in your name, the kind of certificate and its number.</p>
|
|
<% if @user.certificates.any? %>
|
|
<ul class="mt-3 divide-y divide-slate-100 rounded-md ring-1 ring-slate-200">
|
|
<% @user.certificates.each do |c| %>
|
|
<li class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-sm">
|
|
<span><span class="font-medium"><%= c.kind_label %></span> · <%= c.number %>
|
|
<% if c.expires_on %><span class="ml-1 <%= c.expired? ? 'badge-red' : (Date.current + UserCertificate::EXPIRY_WARNING_DAYS >= c.expires_on ? 'badge-orange' : 'badge-gray') %>"><%= c.expired? ? "Expired" : "Expires" %> <%= fmt_date(c.expires_on) %></span><% end %></span>
|
|
<%= button_to "Remove", certificate_path(c), method: :delete, class: "btn-secondary btn-sm", form: { data: { turbo_confirm: "Remove your #{c.kind_label} certificate?" } } %>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
<% end %>
|
|
<%= form_with model: UserCertificate.new, url: certificates_path, class: "mt-3 grid gap-2 sm:grid-cols-[1fr_8rem]" do |f| %>
|
|
<%= f.select :kind, UserCertificate::KINDS.invert, {}, class: "input", "aria-label": "Kind of certificate" %>
|
|
<%= f.text_field :number, class: "input", placeholder: "Number", required: true, maxlength: 40, "aria-label": "Certificate number" %>
|
|
<div class="sm:col-span-2 flex flex-wrap items-end gap-2">
|
|
<div><%= f.label :expires_on, "Expires (optional)", class: "label" %><%= f.date_field :expires_on, class: "input" %></div>
|
|
<%= f.submit "Add certificate", class: "btn-secondary" %>
|
|
</div>
|
|
<p class="hint sm:col-span-2">An Inspection Authorization expires on March 31 of each odd-numbered year unless renewed; you'll be reminded 60 days ahead in the weekly email.</p>
|
|
<% end %>
|
|
</section>
|
|
|
|
<section class="card card-body mt-5 max-w-md">
|
|
<h2 class="card-title">Sessions</h2>
|
|
<% others = @user.sessions.where.not(id: Current.session.id).count %>
|
|
<p class="mt-1 text-sm text-slate-600">
|
|
You're signed in on <%= pluralize(others, "other device or browser", plural: "other devices or browsers") %>.
|
|
Sessions unused for <%= Authentication::SESSION_IDLE_TIMEOUT.inspect %> sign out on their own.
|
|
</p>
|
|
<% if others.positive? %>
|
|
<div class="mt-3"><%= button_to "Sign out everywhere else", other_sessions_path, method: :delete, class: "btn-secondary btn-sm" %></div>
|
|
<% end %>
|
|
</section>
|
|
|
|
<section class="card card-body mt-5 max-w-md">
|
|
<h2 class="card-title">Integrations</h2>
|
|
<p class="mt-1 text-sm text-slate-600">
|
|
<%= link_to "AirTrail sync", air_trail_connection_path, class: "link" %>:
|
|
<%= current_user.air_trail_connection&.enabled? ? "on" : "off" %>. Push the flights you log to your AirTrail flight map automatically.
|
|
</p>
|
|
</section>
|