fix: add password character validation to onboarding single-user setup (#5037)

* fix single user mode password bug

* share const

---------

Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
Marcello Fitton 2026-02-23 19:08:05 -08:00 committed by GitHub
parent c927eda18f
commit 55dc0da488
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -199,7 +199,7 @@ function MultiUserMode() {
);
}
const PW_REGEX = new RegExp(/^[a-zA-Z0-9_\-!@$%^&*();]+$/);
export const PW_REGEX = new RegExp(/^[a-zA-Z0-9_\-!@$%^&*();]+$/);
function PasswordProtection() {
const [saving, setSaving] = useState(false);
const [hasChanges, setHasChanges] = useState(false);

View File

@ -7,6 +7,7 @@ import { useNavigate } from "react-router-dom";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants";
import { useTranslation } from "react-i18next";
import { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH } from "@/utils/username";
import { PW_REGEX } from "@/pages/GeneralSettings/Security";
export default function UserSetup({ setHeader, setForwardBtn, setBackBtn }) {
const { t } = useTranslation();
@ -122,6 +123,15 @@ const JustMe = ({
e.preventDefault();
const form = e.target;
const formData = new FormData(form);
if (!PW_REGEX.test(formData.get("password"))) {
showToast(
`Your password has restricted characters in it. Allowed symbols are _,-,!,@,$,%,^,&,*,(,),;`,
"error"
);
return;
}
const { error } = await System.updateSystemPassword({
usePassword: true,
newPassword: formData.get("password"),