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:
parent
c927eda18f
commit
55dc0da488
@ -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() {
|
function PasswordProtection() {
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [hasChanges, setHasChanges] = useState(false);
|
const [hasChanges, setHasChanges] = useState(false);
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants";
|
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH } from "@/utils/username";
|
import { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH } from "@/utils/username";
|
||||||
|
import { PW_REGEX } from "@/pages/GeneralSettings/Security";
|
||||||
|
|
||||||
export default function UserSetup({ setHeader, setForwardBtn, setBackBtn }) {
|
export default function UserSetup({ setHeader, setForwardBtn, setBackBtn }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -122,6 +123,15 @@ const JustMe = ({
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const form = e.target;
|
const form = e.target;
|
||||||
const formData = new FormData(form);
|
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({
|
const { error } = await System.updateSystemPassword({
|
||||||
usePassword: true,
|
usePassword: true,
|
||||||
newPassword: formData.get("password"),
|
newPassword: formData.get("password"),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user