From a40c27269ac0dad736202a02160677f00c97bb9e Mon Sep 17 00:00:00 2001 From: Marc Brooks Date: Mon, 13 Oct 2025 16:52:14 -0500 Subject: [PATCH] Settings local auth page --- ui/localization/messages/en.json | 42 ++++++++- ...devices.$id.settings.access.local-auth.tsx | 92 +++++++++---------- 2 files changed, 87 insertions(+), 47 deletions(-) diff --git a/ui/localization/messages/en.json b/ui/localization/messages/en.json index 8bb66473..61dbc1ef 100644 --- a/ui/localization/messages/en.json +++ b/ui/localization/messages/en.json @@ -505,5 +505,45 @@ "access_tls_disabled": "Disabled", "access_tls_self_signed": "Self-signed", "access_tls_updated": "TLS settings updated successfully", - "access_update_tls_settings": "Update TLS Settings" + "access_update_tls_settings": "Update TLS Settings", + + "local_auth_change_local_device_password_description": "Enter your current password and a new password to update your local device protection.", + "local_auth_change_local_device_password_title": "Change Local Device Password", + "local_auth_confirm_new_password_label": "Confirm New Password", + "local_auth_create_confirm_password_label": "Confirm New Password", + "local_auth_create_confirm_password_placeholder": "Re-enter your password", + "local_auth_create_description": "Create a password to protect your device from unauthorized local access.", + "local_auth_create_new_password_label": "New Password", + "local_auth_create_new_password_placeholder": "Enter a strong password", + "local_auth_create_not_now_button": "Not Now", + "local_auth_create_secure_button": "Secure Device", + "local_auth_create_title": "Local Device Protection", + "local_auth_current_password_label": "Current Password", + "local_auth_disable_local_device_protection_description": "Enter your current password to disable local device protection.", + "local_auth_disable_local_device_protection_title": "Disable Local Device Protection", + "local_auth_disable_protection_button": "Disable Protection", + "local_auth_enter_current_password_placeholder": "Enter your current password", + "local_auth_enter_new_password_placeholder": "Enter a new strong password", + "local_auth_error_changing_password": "An error occurred while changing the password", + "local_auth_error_disabling_password": "An error occurred while disabling the password", + "local_auth_error_enter_current_password": "Please enter your current password", + "local_auth_error_enter_new_password": "Please enter a new password", + "local_auth_error_enter_old_password": "Please enter your old password", + "local_auth_error_enter_password": "Please enter a password", + "local_auth_error_passwords_not_match": "Passwords do not match", + "local_auth_error_setting_password": "An error occurred while setting the password", + "local_auth_new_password_label": "New Password", + "local_auth_reenter_new_password_placeholder": "Re-enter your new password", + "local_auth_success_password_disabled_description": "You've successfully disabled the password protection for local access. Remember, your device is now less secure.", + "local_auth_success_password_disabled_title": "Password Protection Disabled", + "local_auth_success_password_set_description": "You've successfully set up local device protection. Your device is now secure against unauthorized local access.", + "local_auth_success_password_set_title": "Password Set Successfully", + "local_auth_success_password_updated_description": "You've successfully changed your local device protection password. Make sure to remember your new password for future access.", + "local_auth_success_password_updated_title": "Password Updated Successfully", + "local_auth_update_confirm_password_label": "Confirm New Password", + "local_auth_update_current_password_label": "Current Password", + "local_auth_update_description": "Enter your current password and a new password to update your local device protection.", + "local_auth_update_new_password_label": "New Password", + "local_auth_update_title": "Change Local Device Password", + "local_auth_update_password_button": "Update Password" } \ No newline at end of file diff --git a/ui/src/routes/devices.$id.settings.access.local-auth.tsx b/ui/src/routes/devices.$id.settings.access.local-auth.tsx index 5f5231d3..f0591323 100644 --- a/ui/src/routes/devices.$id.settings.access.local-auth.tsx +++ b/ui/src/routes/devices.$id.settings.access.local-auth.tsx @@ -1,11 +1,12 @@ import { useState, useEffect } from "react"; import { useLocation, useRevalidator } from "react-router"; +import { useLocalAuthModalStore } from "@hooks/stores"; +import { useDeviceUiNavigation } from "@hooks/useAppNavigation"; import { Button } from "@components/Button"; import { InputFieldWithLabel } from "@/components/InputField"; import api from "@/api"; -import { useLocalAuthModalStore } from "@/hooks/stores"; -import { useDeviceUiNavigation } from "@/hooks/useAppNavigation"; +import { m } from "@localizations/messages.js"; export default function SecurityAccessLocalAuthRoute() { const { setModalView } = useLocalAuthModalStore(); @@ -34,12 +35,12 @@ export function Dialog({ onClose }: { onClose: () => void }) { const handleCreatePassword = async (password: string, confirmPassword: string) => { if (password === "") { - setError("Please enter a password"); + setError(m.local_auth_error_enter_password()); return; } if (password !== confirmPassword) { - setError("Passwords do not match"); + setError(m.local_auth_error_passwords_not_match()); return; } @@ -51,11 +52,11 @@ export function Dialog({ onClose }: { onClose: () => void }) { revalidator.revalidate(); } else { const data = await res.json(); - setError(data.error || "An error occurred while setting the password"); + setError(data.error || m.local_auth_error_setting_password()); } } catch (error) { console.error(error); - setError("An error occurred while setting the password"); + setError(m.local_auth_error_setting_password()); } }; @@ -65,17 +66,17 @@ export function Dialog({ onClose }: { onClose: () => void }) { confirmNewPassword: string, ) => { if (newPassword !== confirmNewPassword) { - setError("Passwords do not match"); + setError(m.local_auth_error_passwords_not_match()); return; } if (oldPassword === "") { - setError("Please enter your old password"); + setError(m.local_auth_error_enter_old_password()); return; } if (newPassword === "") { - setError("Please enter a new password"); + setError(m.local_auth_error_enter_new_password()); return; } @@ -91,17 +92,17 @@ export function Dialog({ onClose }: { onClose: () => void }) { revalidator.revalidate(); } else { const data = await res.json(); - setError(data.error || "An error occurred while changing the password"); + setError(data.error || m.local_auth_error_changing_password()); } } catch (error) { console.error(error); - setError("An error occurred while changing the password"); + setError(m.local_auth_error_changing_password()); } }; const handleDeletePassword = async (password: string) => { if (password === "") { - setError("Please enter your current password"); + setError(m.local_auth_error_enter_current_password()); return; } @@ -113,11 +114,11 @@ export function Dialog({ onClose }: { onClose: () => void }) { revalidator.revalidate(); } else { const data = await res.json(); - setError(data.error || "An error occurred while disabling the password"); + setError(data.error || m.local_auth_error_disabling_password()); } } catch (error) { console.error(error); - setError("An error occurred while disabling the password"); + setError(m.local_auth_error_disabling_password()); } }; @@ -150,24 +151,24 @@ export function Dialog({ onClose }: { onClose: () => void }) { {modalView === "creationSuccess" && ( )} {modalView === "deleteSuccess" && ( )} {modalView === "updateSuccess" && ( )} @@ -198,24 +199,24 @@ function CreatePasswordModal({ >

- Local Device Protection + {m.local_auth_create_title()}

- Create a password to protect your device from unauthorized local access. + {m.local_auth_create_description()}

setPassword(e.target.value)} /> setConfirmPassword(e.target.value)} /> @@ -224,10 +225,10 @@ function CreatePasswordModal({