2023-08-06 17:35:16 -07:00
|
|
|
<h2>Settings</h2>
|
2023-08-06 17:26:56 -07:00
|
|
|
|
2024-04-08 04:02:54 -07:00
|
|
|
<%= form_with(model: @auth_user, method: :put, class: "settings-form") do |f| %>
|
2024-04-07 06:40:15 -07:00
|
|
|
<h2>Your info</h2>
|
2024-04-08 04:02:54 -07:00
|
|
|
<%= render "devise/shared/error_messages", resource: @auth_user %>
|
2023-08-06 17:26:56 -07:00
|
|
|
|
2024-04-07 06:40:15 -07:00
|
|
|
<fieldset>
|
|
|
|
<div class="field">
|
|
|
|
<%= f.label :name, 'DTI Username' %>
|
|
|
|
<span class="hint">Use this to log in to Dress to Impress!</span>
|
2023-08-06 17:26:56 -07:00
|
|
|
<br />
|
2024-04-07 06:40:15 -07:00
|
|
|
<%= f.text_field :name, autocomplete: "username" %>
|
|
|
|
</div>
|
2023-08-06 17:26:56 -07:00
|
|
|
|
2024-04-07 06:40:15 -07:00
|
|
|
<div class="field">
|
|
|
|
<%= f.label :email %>
|
|
|
|
<span class="hint">This can help you recover your account later.</span>
|
|
|
|
<br />
|
|
|
|
<%= f.email_field :email, autocomplete: "email" %>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<div class="field">
|
|
|
|
<%= f.label :password, "New password" %>
|
|
|
|
<span class="hint">Leave blank if you don't want to change it.</span>
|
|
|
|
<br />
|
|
|
|
<%= f.password_field :password, autocomplete: "new-password" %>
|
|
|
|
<% if @minimum_password_length %>
|
|
|
|
<br />
|
|
|
|
<span class="hint"><%= @minimum_password_length %> characters minimum</span>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<%= f.label :password_confirmation, "New password confirmation" %><br />
|
|
|
|
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
|
2024-04-08 04:13:07 -07:00
|
|
|
<%# Current password is only required if you have one! %>
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
<% if @persisted_auth_user.uses_password? %>
|
2024-04-08 04:13:07 -07:00
|
|
|
<fieldset>
|
|
|
|
<div class="field">
|
|
|
|
<%= f.label :current_password %>
|
|
|
|
<span class="hint">We need your current password to confirm your changes.</span>
|
|
|
|
<br />
|
|
|
|
<%= f.password_field :current_password, autocomplete: "current-password" %>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<% end %>
|
2023-08-06 17:26:56 -07:00
|
|
|
|
|
|
|
<div class="actions">
|
2024-04-07 06:40:15 -07:00
|
|
|
<%= f.submit "Save changes" %>
|
2023-08-06 17:26:56 -07:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
<% if @persisted_auth_user.uses_neopass? %>
|
2024-04-08 04:02:54 -07:00
|
|
|
<%= form_with url: user_neopass_connection_path(@auth_user.user),
|
|
|
|
method: :delete, class: "settings-form", data: {
|
2024-04-07 07:52:23 -07:00
|
|
|
turbo_confirm: "Are you sure? Without a NeoPass, you'll need to use " +
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
"your password or your recovery email " +
|
|
|
|
"\"#{@persisted_auth_user.email}\" to log in again.\n\nMake sure " +
|
|
|
|
"you have everything all set up first! Otherwise, you might be " +
|
|
|
|
"locked out of this account forever!"
|
2024-04-07 07:52:23 -07:00
|
|
|
} do |form|
|
|
|
|
%>
|
2024-04-07 07:17:33 -07:00
|
|
|
<h2>Your NeoPass</h2>
|
|
|
|
<section class="neopass-info">
|
|
|
|
<strong>
|
|
|
|
NeoPass ID:
|
|
|
|
</strong>
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
<%= @persisted_auth_user.neopass_friendly_id %>
|
2024-04-07 07:17:33 -07:00
|
|
|
</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>
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
<% if !@persisted_auth_user.uses_password? && !@persisted_auth_user.email? %>
|
2024-04-07 08:27:02 -07:00
|
|
|
<p>
|
|
|
|
You can't remove this NeoPass yet, because you need to either set a
|
|
|
|
password or a recovery email first. (Ideally both!)
|
|
|
|
</p>
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
<% elsif !@persisted_auth_user.uses_password? %>
|
2024-04-07 08:27:02 -07:00
|
|
|
<p>
|
|
|
|
Be extra careful here! Your account doesn't have a password set.
|
|
|
|
</p>
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
<% elsif !@persisted_auth_user.email? %>
|
2024-04-07 08:27:02 -07:00
|
|
|
<p>
|
|
|
|
Be extra careful here! Your account doesn't have an email set.
|
|
|
|
</p>
|
|
|
|
<% end %>
|
2024-04-07 07:17:33 -07:00
|
|
|
</section>
|
2024-04-07 08:27:02 -07:00
|
|
|
<%= form.submit "Disconnect your NeoPass",
|
Fix bugs in Settings page when changes to the model are incomplete
Ahh okay tricky lil thing: if you show the settings page with a partial
change to `AuthUser` that didn't get saved, it can throw off the state
of some stuff. For example, if you don't have a password yet, then
enter a new password but leave the confirmation box blank, then you'll
correctly see "Password confirmation can't be blank", but you'll *also*
then be prompted for your "Current password", even though you don't
have one yet, because `@auth_user.uses_password?` is true now.
In this change, we extend the Settings form to use two copies of the
`AuthUser`. One is the copy with changes on it, and the other is the
"persisted" copy, which we check for parts of the UI that care about
what's actually saved, vs form state.
2024-04-09 06:23:54 -07:00
|
|
|
disabled: !@persisted_auth_user.uses_password? &&
|
|
|
|
!@persisted_auth_user.email? %>
|
2024-04-07 07:17:33 -07:00
|
|
|
<% end %>
|
2024-04-12 06:51:20 -07:00
|
|
|
<% else %>
|
2024-04-08 05:33:58 -07:00
|
|
|
<%= form_with url: auth_user_neopass_omniauth_authorize_path(intent: "connect"),
|
|
|
|
method: :post, class: "settings-form", data: {turbo: false} do |form|
|
|
|
|
%>
|
|
|
|
<h2>Your NeoPass</h2>
|
|
|
|
<section class="neopass-explanation">
|
|
|
|
<p>
|
|
|
|
If you connect a NeoPass, you can use it to log into this DTI account!
|
2024-04-12 07:14:34 -07:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
When you click below, you'll be connected to
|
|
|
|
<%= link_to "https://account.neopets.com/", target: "_blank" do %>
|
|
|
|
whatever NeoPass is already logged in
|
|
|
|
<%= external_link_icon %><% end %>.
|
|
|
|
If it's your first time connecting, you'll be asked for 3 permissions:
|
|
|
|
<em>OpenID</em> and <em>Email</em> tell us who you are, and
|
|
|
|
<em>Linkage</em> tells us your Neopets username.
|
|
|
|
</p>
|
|
|
|
<p>
|
2024-04-08 05:33:58 -07:00
|
|
|
You'll still be able to use your password to log in too, and you can
|
|
|
|
disconnect this later if you'd like.
|
|
|
|
</p>
|
|
|
|
</section>
|
|
|
|
<%= form.submit "Connect your NeoPass" %>
|
|
|
|
<% end %>
|
2024-04-07 07:17:33 -07:00
|
|
|
<% end %>
|
|
|
|
|
2024-04-07 06:40:15 -07:00
|
|
|
<% content_for :stylesheets do %>
|
2024-04-08 04:02:54 -07:00
|
|
|
<%= stylesheet_link_tag "auth_users/edit" %>
|
2024-04-07 06:40:15 -07:00
|
|
|
<% end %>
|