Files
ubicloud/views/account/change_password.erb
Enes Cakir a52972561e Allow to delete password if another login method is available
If the user has another login method, they can delete their password.
This is helpful for users who prefer to use only one login method.

If the user doesn't have a password, they can create a new one using the
"Change Password" feature. I changed "Change" to "Create" for clarity
when the user doesn’t have a password.
2024-12-30 12:22:26 +03:00

42 lines
2.1 KiB
Plaintext

<% action = rodauth.has_password? ? "Change" : "Create"
@page_title = "#{action} Password" %>
<%== render("components/page_header", locals: { title: "My Account" }) %>
<main>
<div class="max-w-screen-xl pb-6 lg:pb-16">
<div class="overflow-hidden rounded-lg bg-white shadow">
<div class="divide-y divide-gray-200 lg:grid lg:grid-cols-12 lg:divide-x lg:divide-y-0">
<%== render("account/submenu") %>
<div class="divide-y divide-gray-200 lg:col-span-8 xl:col-span-9 2xl:col-span-10 pb-10">
<div class="px-4 py-6 sm:p-6 lg:pb-8 space-y-4">
<h2 class="text-lg font-medium leading-6 text-gray-900"><%= action %> Password</h2>
<form action="/<%= rodauth.change_password_route %>" role="form" method="POST">
<%== rodauth.change_password_additional_form_tags %>
<%== rodauth.csrf_tag("/" + rodauth.change_password_route) %>
<div class="mt-6 grid grid-cols-6 gap-6">
<% if rodauth.change_password_requires_password? %>
<div class="col-span-6 sm:col-span-3 xl:col-span-2">
<%== render("components/rodauth/password_field", locals: {label: "Current Password"}) %>
</div>
<% end %>
<div class="col-span-6 sm:col-span-3 xl:col-span-2">
<%== render("components/rodauth/password_field", locals: {label: "#{rodauth.new_password_label}#{rodauth.input_field_label_suffix}", name: rodauth.new_password_param, autocomplete: "new-password"}) %>
</div>
<% if rodauth.require_password_confirmation? %>
<div class="col-span-6 sm:col-span-3 xl:col-span-2">
<%== render("components/rodauth/password_field", locals: {label: "New Password Confirmation", confirm: true}) %>
</div>
<% end %>
<div class="col-span-6">
<%== render("components/form/submit_button", locals: { text: "#{action} Password" }) %>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>