Disable disconnecting NeoPass if no password/email is set

Just as a precautionary thing! Seems polite.
This commit is contained in:
Emi Matchu 2024-04-07 08:27:02 -07:00
parent b827727102
commit 54a052848a
3 changed files with 26 additions and 5 deletions

View file

@ -41,17 +41,19 @@
padding: .5em .75em .45em
color: #fff
text-decoration: none
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5)
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5)
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5)
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25)
border-bottom: 1px solid rgba(0, 0, 0, 0.25)
position: relative
font-weight: bold
line-height: 1
&:hover
&:hover:not(:disabled)
color: #fff
&:active
&:active:not(:disabled)
transform: translateY(1px)
&:disabled
background: #999999 image-url("alert-overlay.png") repeat-x
cursor: not-allowed
=reset-awesome-button
border-radius: 0

View file

@ -48,6 +48,10 @@ class AuthUser < AuthRecord
neopass_email || uid
end
def uses_password?
encrypted_password?
end
def disconnect_neopass
# If there's no NeoPass, we're already done!
return true if !uses_neopass?

View file

@ -75,8 +75,23 @@
you can still use "Forgot your password?" to recover your Dress to
Impress account, using the Email saved in "Your info".
</p>
<% if !resource.uses_password? && !resource.email %>
<p>
You can't remove this NeoPass yet, because you need to either set a
password or a recovery email first. (Ideally both!)
</p>
<% elsif !resource.uses_password? %>
<p>
Be extra careful here! Your account doesn't have a password set.
</p>
<% elsif !resource.email? %>
<p>
Be extra careful here! Your account doesn't have an email set.
</p>
<% end %>
</section>
<%= form.submit "Disconnect your NeoPass" %>
<%= form.submit "Disconnect your NeoPass",
disabled: !resource.uses_password? && !resource.email? %>
<% end %>
<% end %>