Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6444d7afa7 | ||
|
|
daa984a48f | ||
|
|
383bd15263 | ||
|
|
1e44e8ddfb | ||
|
|
cc875b4e22 | ||
|
|
4ee885ac57 |
No files matched your search
@@ -106,53 +106,6 @@ app.get('/reset/:token', async (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/resetLink', async (req, res) => {
|
|
||||||
const { token, password, confirmPassword, } = req.body;
|
|
||||||
const passwordSchema = joi.object({
|
|
||||||
password: joi.string().max(20).required(),
|
|
||||||
confirmPassword: joi.string().max(20).required(),
|
|
||||||
});
|
|
||||||
const valid = passwordSchema.validate({ password, confirmPassword });
|
|
||||||
if (valid.error) {
|
|
||||||
console.log("houston we have a problem");
|
|
||||||
req.session.error = 'Invalid input';
|
|
||||||
res.status(status.BadRequest);
|
|
||||||
return res.redirect(`/reset/${token}`);
|
|
||||||
}
|
|
||||||
if (!token || !password || !confirmPassword) {
|
|
||||||
req.session.error = 'field may be missing';
|
|
||||||
return res.redirect(`/reset/${token}`);
|
|
||||||
}
|
|
||||||
if (password !== confirmPassword) {
|
|
||||||
req.session.error = 'passwords do not match';
|
|
||||||
return res.redirect(`/reset/${token}`);
|
|
||||||
}
|
|
||||||
const user = await users.findOne({
|
|
||||||
resetToken: token,
|
|
||||||
resetTokenExpires: { $gt: Date.now() },
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
req.session.error = 'Reset link is invalid.';
|
|
||||||
return res.redirect(`/reset`);
|
|
||||||
}
|
|
||||||
const hashPassword = await bcrypt.hash(password, 12);
|
|
||||||
|
|
||||||
await users.updateOne(
|
|
||||||
{
|
|
||||||
email: user.email
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$set: {
|
|
||||||
password: hashPassword,
|
|
||||||
resetToken: '',
|
|
||||||
resetTokenExpires: 0,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
req.session.success = 'Password has been reset';
|
|
||||||
res.redirect('/login');
|
|
||||||
});
|
|
||||||
|
|
||||||
// 404 handler - keep the actual notFound route please
|
// 404 handler - keep the actual notFound route please
|
||||||
// REALLY DONT DELETE THIS
|
// REALLY DONT DELETE THIS
|
||||||
|
|||||||
Generated
+1
@@ -1442,6 +1442,7 @@
|
|||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
|
||||||
"integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw==",
|
"integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw==",
|
||||||
|
"license": "MIT-0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -163,7 +163,7 @@ module.exports = (middleware, users, plans, assets) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get('/newPlan', (req, res) => {
|
router.get('/newPlan', (req, res) => {
|
||||||
if (!req.session.user.financialData) {
|
if (!req.session.user.financialData || !req.session.user) {
|
||||||
req.session.errMessage = "Please complete your financial data before creating a plan.";
|
req.session.errMessage = "Please complete your financial data before creating a plan.";
|
||||||
return res.status(status.Unauthorized).redirect('/questionnaire');
|
return res.status(status.Unauthorized).redirect('/questionnaire');
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,13 @@ module.exports = (middleware, users, plans, assets) => {
|
|||||||
|
|
||||||
req.session.user.financialData = true;
|
req.session.user.financialData = true;
|
||||||
req.session.errMessage = "";
|
req.session.errMessage = "";
|
||||||
res.status(status.Ok).redirect("/home");
|
|
||||||
|
req.session.save(err => {
|
||||||
|
if (err) {
|
||||||
|
res.status(status.InternalServerError).redirect("/plans");
|
||||||
|
}
|
||||||
|
res.status(status.Ok).redirect("/plans");
|
||||||
|
});
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error("Error updating questionnaire in database:", err);
|
console.error("Error updating questionnaire in database:", err);
|
||||||
|
|||||||
@@ -7,5 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<!-- Get geolocation if not in session and load conversion rates -->
|
<!-- Get geolocation if not in session and load conversion rates -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
|
||||||
<script src="/static/scripts/geolocation.js"></script>
|
<script src="/static/scripts/geolocation.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// If no geoData provided thorugh EJS, send update request to backend
|
// If no geoData provided thorugh EJS, send update request to backend
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
<% plans.forEach(plan => { %>
|
<% plans.forEach(plan => { %>
|
||||||
<a href="/plans/<%= plan._id %>" class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
|
<a href="/plans/<%= plan._id %>" class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
|
||||||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"><%= plan.name %></h5>
|
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"><%= plan.name %></h5>
|
||||||
<div class="w-full bg-gray-200 rounded-full h-2.5 mb-4 dark:bg-gray-700">
|
<div class="w-full bg-black rounded-full h-2.5 mb-4 dark:bg-black">
|
||||||
<div class="bg-green-600 h-2.5 rounded-full dark:bg-green-500" style="width: <%= plan.progress %>%;"></div>
|
<div class="bg-green-600 h-2.5 rounded-full dark:bg-green-500" style="width: <%= plan.progress %>%;"></div>
|
||||||
</div>
|
</div>
|
||||||
<p class="font-normal text-gray-700 dark:text-gray-400"><%= plan.description %></p>
|
<p class="font-normal text-gray-700 dark:text-gray-400"><%= plan.description %></p>
|
||||||
|
|||||||
Reference in new issue
Block a user