Skip to content

Commit

Permalink
password special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
AldemirLucas committed Feb 8, 2024
1 parent 542ca95 commit 7dd8941
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions next/pages/user/[username].js
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ const NewPassword = ({ userInfo }) => {
if(!/(?=.*?[0-9])/.test(formData.newPassword)) {
regexPassword = {...regexPassword, number: true}
}
if(!/^[!@#?!%^&*-_+=,:;<>,.?|]*$/.test(formData.newPassword)) {
if(!/[!@#?!%&*]/.test(formData.newPassword)) {
regexPassword = {...regexPassword, special: true}
}
if (!formData.confirmPassword) {
Expand Down Expand Up @@ -1125,7 +1125,11 @@ const NewPassword = ({ userInfo }) => {
const form = {id: id, password: formData.newPassword, token: getTokenPassword?.tokenAuth?.token}

const result = await updatePassword(form)
setFormData({})
setFormData({
password: "",
newPassword: "",
confirmPassword: ""
})

newPasswordModal.onOpen()
}
Expand Down Expand Up @@ -1315,10 +1319,7 @@ const NewPassword = ({ userInfo }) => {
<ListItem fontSize="12px" color={errors?.regexPassword?.upperCase ? "#D93B3B" :"#7D7D7D"}>Uma letra maiúscula</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.lowerCase ? "#D93B3B" :"#7D7D7D"}>Uma letra minúscula</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.number ? "#D93B3B" :"#7D7D7D"}>Um dígito</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.special ? "#D93B3B" :"#7D7D7D"}>Um caractere especial</ListItem>
{/*
^[!@#?!%^&*-_+=,:;<>,.?|]*$
*/}
<ListItem fontSize="12px" color={errors?.regexPassword?.special ? "#D93B3B" :"#7D7D7D"}>Um caractere especial, dentre ! @ # ? ! % & *</ListItem>
</UnorderedList>
{errors.newPassword &&
<FormErrorMessage fontFamily="ubuntu" fontSize="12px" color="#D93B3B" display="flex" flexDirection="row" gap="4px" alignItems="center">
Expand Down
4 changes: 2 additions & 2 deletions next/pages/user/password-recovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function PasswordRecovery({ confirmed, uid, confirmToken }) {
if(!/(?=.*?[0-9])/.test(formData.password)) {
regexPassword = {...regexPassword, number: true}
}
if(!/^[!@#?!%^&*-_+=,:;<>,.?|]*$/.test(formData.password)) {
if(!/[!@#?!%&*]/.test(formData.password)) {
regexPassword = {...regexPassword, special: true}
}
if (!formData.confirmPassword) {
Expand Down Expand Up @@ -253,7 +253,7 @@ export default function PasswordRecovery({ confirmed, uid, confirmToken }) {
<ListItem fontSize="12px" color={errors?.regexPassword?.upperCase ? "#D93B3B" :"#7D7D7D"}>Uma letra maiúscula</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.lowerCase ? "#D93B3B" :"#7D7D7D"}>Uma letra minúscula</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.number ? "#D93B3B" :"#7D7D7D"}>Um dígito</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.special ? "#D93B3B" :"#7D7D7D"}>Um caractere especial</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.special ? "#D93B3B" :"#7D7D7D"}>Um caractere especial, dentre ! @ # ? ! % & *</ListItem>
</UnorderedList>
{errors.password &&
<FormErrorMessage fontFamily="ubuntu" fontSize="12px" color="#D93B3B" display="flex" flexDirection="row" gap="4px" alignItems="center">
Expand Down
4 changes: 2 additions & 2 deletions next/pages/user/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function Register() {
if(!/(?=.*?[0-9])/.test(formData.password)) {
regexPassword = {...regexPassword, number: true}
}
if(!/^[!@#?!%^&*-_+=,:;<>,.?|]*$/.test(formData.password)) {
if(!/[!@#?!%&*]/.test(formData.password)) {
regexPassword = {...regexPassword, special: true}
}
if (!formData.confirmPassword) {
Expand Down Expand Up @@ -286,7 +286,7 @@ export default function Register() {
<ListItem fontSize="12px" color={errors?.regexPassword?.upperCase ? "#D93B3B" :"#7D7D7D"}>Uma letra maiúscula</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.lowerCase ? "#D93B3B" :"#7D7D7D"}>Uma letra minúscula</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.number ? "#D93B3B" :"#7D7D7D"}>Um dígito</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.special ? "#D93B3B" :"#7D7D7D"}>Um caractere especial</ListItem>
<ListItem fontSize="12px" color={errors?.regexPassword?.special ? "#D93B3B" :"#7D7D7D"}>Um caractere especial, dentre ! @ # ? ! % & *</ListItem>
</UnorderedList>
</FormControl>

Expand Down

0 comments on commit 7dd8941

Please sign in to comment.