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

Issue 140 n 139 fixed #157

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ app.use(
})
);
app.use(express.static("public"));
app.use(session(sessionConfig));
app.use(session({
...sessionConfig,
secret: "your-secret-key"
}));
app.use(express.json());
app.use(passport.initialize());
app.use(passport.session());
Expand Down
1 change: 1 addition & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGODB_URI = mongodb://localhost:27017
47 changes: 47 additions & 0 deletions views/signup.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
border-radius: 4px;
color: black;
"
oninput="checkPasswordStrength(this.value)"
/>
<span id="passwordStrength"></span>

<button
type="submit"
Expand All @@ -78,6 +80,51 @@
</button>
</form>
</section>
<script>
function checkPasswordStrength(password) {
var passwordStrength = document.getElementById("passwordStrength");
var strength = 0;

// Check password length
if (password.length >= 8) {
strength += 1;
}

// Check for uppercase letters
if (/[A-Z]/.test(password)) {
strength += 1;
}

// Check for lowercase letters
if (/[a-z]/.test(password)) {
strength += 1;
}

// Check for numbers
if (/[0-9]/.test(password)) {
strength += 1;
}

// Check for special characters
if (/[^A-Za-z0-9]/.test(password)) {
strength += 1;
}

// Update password strength indicator
if (strength == 0) {
passwordStrength.innerHTML = "";
} else if (strength <= 2) {
passwordStrength.innerHTML = "Weak";
passwordStrength.style.color = "red";
} else if (strength <= 4) {
passwordStrength.innerHTML = "Medium";
passwordStrength.style.color = "orange";
} else {
passwordStrength.innerHTML = "Strong";
passwordStrength.style.color = "green";
}
}
</script>
</main>

<%- include("partials/footer"); -%>
Loading