Skip to content
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
7 changes: 7 additions & 0 deletions public/js/interactivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ function applyJob(body) {
}

function handleLogin(username, password) {
const registrationSuccess = sessionStorage.getItem('registrationSuccess');
if (registrationSuccess) {
sessionStorage.removeItem('registrationSuccess');
window.location.href = '/login.ejs';
return;
}

fetch('/login', {
method: 'POST',
headers: {
Expand Down
2 changes: 1 addition & 1 deletion routes/authRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ router.post('/register', async (req, res) => {
const user = new User({ username, password, email, domainOfInterest, linkedinUrl, currentCompany, currentLevel });
await user.save();
req.session.userId = user._id;
res.status(201).json({ message: 'User registered successfully', userId: user._id });
res.redirect('/login');
} catch (error) {
res.status(500).json({ message: 'Error registering user', error: error.message });
}
Expand Down
11 changes: 10 additions & 1 deletion routes/middleware/authMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ const requireRole = (role) => {
};
};

module.exports = { requireAuth, alreadyLoggedIn, requireRole };
const checkRegistrationComplete = (req, res, next) => {
if (req.session.registrationComplete) {
next();
} else {
res.redirect('/complete-registration');
}
};

module.exports = { requireAuth, alreadyLoggedIn, requireRole, checkRegistrationComplete };
```
12 changes: 11 additions & 1 deletion views/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@
button:hover {
background-color: #0056b3;
}
.error-message {
.error-message, .success-message {
color: #d9534f;
margin-bottom: 10px;
}
.success-message {
color: #28a745;
}
p {
text-align: center;
}
Expand All @@ -77,6 +80,11 @@
<%= errorMessage %>
</div>
<% } %>
<% if (typeof successMessage !== 'undefined') { %>
<div class="success-message">
<%= successMessage %>
</div>
<% } %>
<form action="/login" method="POST" id="loginForm">
<div class="form-group">
<label for="username">Username:</label>
Expand All @@ -99,3 +107,5 @@
});
</script>
</body>

</html>
12 changes: 6 additions & 6 deletions views/register.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@
box-sizing: border-box;
}
select {
/* Additional styling for the dropdown */
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
padding-right: 30px; /* Adjust based on the width of the arrow icon */
background-image: url('path_to_arrow_icon'); /* Add an arrow icon */
padding-right: 30px;
background-image: url('path_to_arrow_icon');
background-position: right center;
background-repeat: no-repeat;
}
/* Style the dropdown arrow */
select::-ms-expand {
display: none;
}
Expand All @@ -74,7 +72,7 @@
color: #007bff;
}
</style>
<link rel="stylesheet" href="css/style.css"> <!-- Keeping the original stylesheet -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
Expand Down Expand Up @@ -142,7 +140,9 @@
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
<p>Thank you for registering! <a href="/login" class="btn btn-success">Proceed to Login</a></p>
<p>Already have an account? <a href="/login">Login here</a>.</p>
</div>
<script src="js/interactivity.js"></script>
</body>
</body>
</html>