Add some NeoPass info to the Settings page, if you have one

No buttons to change it or anything, or to link if you don't! Just a
basic display and explanation!
This commit is contained in:
Emi Matchu 2024-04-07 07:17:33 -07:00
parent d5c3bc087e
commit 21b967f83d
4 changed files with 42 additions and 0 deletions

View file

@ -6,6 +6,9 @@
border-radius: 1em
padding: 1em 1.25em
&:not(:last-of-type)
margin-bottom: 2em
h2
font-size: 1.5rem
margin-bottom: .25em
@ -44,3 +47,12 @@
ul
padding-left: 2em
.neopass-info
margin-bottom: .5em
.neopass-explanation
font-size: .85em
p:last-of-type
margin-bottom: 0

View file

@ -40,6 +40,14 @@ class AuthUser < AuthRecord
super && !uses_omniauth?
end
def neopass?
provider == "neopass"
end
def neopass_friendly_id
neopass_email || uid
end
def self.from_omniauth(auth)
raise MissingAuthInfoError, "Email missing" if auth.info.email.blank?

View file

@ -4,6 +4,7 @@ class User < ApplicationRecord
PreviewTopContributorsCount = 3
belongs_to :auth_user, foreign_key: :remote_id, inverse_of: :user
delegate :neopass?, to: :auth_user
has_many :closet_hangers
has_many :closet_lists

View file

@ -52,6 +52,27 @@
</div>
<% end %>
<% if resource.neopass? %>
<%= form_with model: resource, url: registration_path(resource_name),
html: { method: :put, class: "settings-form" } do |form| %>
<h2>Your NeoPass</h2>
<section class="neopass-info">
<strong>
NeoPass ID:
</strong>
<%= resource.neopass_friendly_id %>
</section>
<section class="neopass-explanation">
<p>
You can log into your Dress to Impress account with NeoPass, or with
your username and password. If you ever lose access to your NeoPass,
you can still use "Forgot your password?" to recover your Dress to
Impress account, using the Email saved in "Your info".
</p>
</section>
<% end %>
<% end %>
<% content_for :stylesheets do %>
<%= stylesheet_link_tag "devise/registrations/edit" %>
<% end %>