From 21b967f83d3732a6a1037e170d2663538b23efdf Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 7 Apr 2024 07:17:33 -0700 Subject: [PATCH] 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! --- .../devise/registrations/edit.sass | 12 +++++++++++ app/models/auth_user.rb | 8 +++++++ app/models/user.rb | 1 + app/views/devise/registrations/edit.html.erb | 21 +++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/app/assets/stylesheets/devise/registrations/edit.sass b/app/assets/stylesheets/devise/registrations/edit.sass index 88c2e169..f003c168 100644 --- a/app/assets/stylesheets/devise/registrations/edit.sass +++ b/app/assets/stylesheets/devise/registrations/edit.sass @@ -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 diff --git a/app/models/auth_user.rb b/app/models/auth_user.rb index 30149a32..17424324 100644 --- a/app/models/auth_user.rb +++ b/app/models/auth_user.rb @@ -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? diff --git a/app/models/user.rb b/app/models/user.rb index a6050a8f..e78f646c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3ba3962c..15aa2502 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -52,6 +52,27 @@ <% end %> +<% if resource.neopass? %> + <%= form_with model: resource, url: registration_path(resource_name), + html: { method: :put, class: "settings-form" } do |form| %> +

Your NeoPass

+
+ + NeoPass ID: + + <%= resource.neopass_friendly_id %> +
+
+

+ 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". +

+
+ <% end %> +<% end %> + <% content_for :stylesheets do %> <%= stylesheet_link_tag "devise/registrations/edit" %> <% end %>