Adjusted password form field namings
This commit is contained in:
1 parent
e6ea59dee5
commit
bb42bfc00a
2 files changed
+8
-7
No files matched your search
@@ -24,13 +24,14 @@ const PasswordPanel = () => {
|
|||||||
|
|
||||||
//for testing, will tweak when I implement redux slice
|
//for testing, will tweak when I implement redux slice
|
||||||
const idToName = {
|
const idToName = {
|
||||||
"edit-current-password": "currentPassword",
|
"edit-current-password": "password",
|
||||||
"edit-new-password": "password",
|
//TBD - form field naming
|
||||||
|
"edit-new-password": "newpassword",
|
||||||
"edit-confirm-password": "confirm",
|
"edit-confirm-password": "confirm",
|
||||||
};
|
};
|
||||||
const [localData, setLocalData] = useState({
|
const [localData, setLocalData] = useState({
|
||||||
currentPassword: "",
|
|
||||||
password: "",
|
password: "",
|
||||||
|
newpassword: "",
|
||||||
confirm: "",
|
confirm: "",
|
||||||
});
|
});
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
@@ -45,7 +46,7 @@ const PasswordPanel = () => {
|
|||||||
|
|
||||||
const validation = editPasswordValidation.validate(
|
const validation = editPasswordValidation.validate(
|
||||||
{ [name]: value },
|
{ [name]: value },
|
||||||
{ abortEarly: false, context: { password: localData.password } }
|
{ abortEarly: false, context: { newpassword: localData.newpassword } }
|
||||||
);
|
);
|
||||||
|
|
||||||
setErrors((prev) => {
|
setErrors((prev) => {
|
||||||
@@ -66,7 +67,7 @@ const PasswordPanel = () => {
|
|||||||
|
|
||||||
const { error } = editPasswordValidation.validate(localData, {
|
const { error } = editPasswordValidation.validate(localData, {
|
||||||
abortEarly: false,
|
abortEarly: false,
|
||||||
context: { password: localData.password },
|
context: { newpassword: localData.newpassword },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -84,12 +84,12 @@ const editProfileValidation = joi.object({
|
|||||||
|
|
||||||
const editPasswordValidation = joi.object({
|
const editPasswordValidation = joi.object({
|
||||||
// TBD - validation for current password ?
|
// TBD - validation for current password ?
|
||||||
currentPassword : joi
|
password : joi
|
||||||
.string().trim()
|
.string().trim()
|
||||||
.messages({
|
.messages({
|
||||||
"string.empty": "*Current password is required.",
|
"string.empty": "*Current password is required.",
|
||||||
}),
|
}),
|
||||||
password: joi
|
newpassword: joi
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(8)
|
.min(8)
|
||||||
|
|||||||
Reference in new issue
Block a user