Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased password complexity and added input validation #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions com-dict-client/src/components/Login/loginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const NormalLoginForm = () => {
<Form.Item
name="email"
rules={[
{
type: "email",
message: "The input is not a valid Email address!",
},
{
required: true,
message: "Please input your Email Address!",
Expand Down
44 changes: 44 additions & 0 deletions com-dict-client/src/components/Signup/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,50 @@ const RegistrationForm = () => {
required: true,
message: "Please input your password!",
},
({ getFieldValue }) => ({
validator(rule, value) {
var c = 0;
if (!value || value.length < 8) {
return Promise.reject("Enter a strong password with minimum 8 characters!");
}
// check for a number
if (/[0-9]/.test(value) === false) {
c = c + 0;
}
else {
c++;
}
// check for a capital letter
if (/[A-Z]/.test(value) === false) {
c = c + 0;
}
else {
c++;
}
// check for a lowercase letter
if (/[a-z]/.test(value) === false) {
c = c + 0;
}
else {
c++;
}
// check for punctuation mark
if (/[@#$&*^%_!+=/[\]|?.,<>)(;:'"~`]/.test(value) === false) {
c = c + 0;
}
else {
c++;
}

if (c >= 3) {
return Promise.resolve();
}
else {
return Promise.reject("The password must contain at least three of these four character categories: English uppercase , English lowercase , Number and Non - alphanumeric");
}
}
}
),
]}
hasFeedback
>
Expand Down