Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1626f6ae9 | ||
|
|
83be006a83 | ||
|
|
6d91934229
|
||
|
|
97a1473e21
|
||
|
|
3bb9ede515
|
||
|
|
b350cdad9f
|
||
|
|
f0d324151d
|
||
|
|
b88333e3b4
|
||
|
|
75bc3bee8f
|
||
|
|
a2b4e8d36d
|
||
|
|
033401dbf7
|
No files matched your search
@@ -12,7 +12,7 @@ const port = process.env.PORT || 3000;
|
|||||||
|
|
||||||
const mongoURI = process.env.mongoURI || "mongodb://localhost:27017/";
|
const mongoURI = process.env.mongoURI || "mongodb://localhost:27017/";
|
||||||
const database = process.env.database || "knoldus"; // Database name
|
const database = process.env.database || "knoldus"; // Database name
|
||||||
const secret = process.env.secret || "123-secret-xyz";
|
const secret = process.env.secret || "123-secret-xyz";
|
||||||
|
|
||||||
/*** Sessions ***/
|
/*** Sessions ***/
|
||||||
app.use(session({
|
app.use(session({
|
||||||
@@ -24,10 +24,11 @@ app.use(session({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
app.set('view engine', 'ejs');
|
app.set('view engine', 'ejs');
|
||||||
app.set('views', path.join(__dirname, 'src/views'));
|
app.set('views',path.join(__dirname, 'src/views'));
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use("/static", express.static("./src/public"));
|
app.use("/static", express.static("./src/public"));
|
||||||
app.use("/images", express.static("./src/public/images"));
|
app.use("/images", express.static("./src/public/images"));
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
/*** Database ***/
|
/*** Database ***/
|
||||||
const { connectMongo, getCollection } = require("./src/database/connection");
|
const { connectMongo, getCollection } = require("./src/database/connection");
|
||||||
@@ -44,11 +45,13 @@ async function initDatabase() {
|
|||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
if (!req.session.errMessage) req.session.errMessage = "";
|
if (!req.session.errMessage) req.session.errMessage = "";
|
||||||
res.render('dashboard');
|
res.render('landing');
|
||||||
return res.status(status.Ok);
|
return res.status(status.Ok);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/signup', (req, res) => {
|
app.get('/signup', (req, res) => {
|
||||||
|
const ignore = ["User not found", "Incorrect password"];
|
||||||
|
if (ignore.includes(req.session.errMessage)) req.session.errMessage = "";
|
||||||
res.render('signup', { errMessage: req.session.errMessage });
|
res.render('signup', { errMessage: req.session.errMessage });
|
||||||
return res.status(status.Ok);
|
return res.status(status.Ok);
|
||||||
});
|
});
|
||||||
@@ -67,6 +70,15 @@ app.get('/aboutUs', (req, res) => {
|
|||||||
return res.status(status.Ok);
|
return res.status(status.Ok);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.post('/api/location', async (req,res) => {
|
||||||
|
const { latitude, longitude } = req.body;
|
||||||
|
|
||||||
|
const response = await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${latitude},${longitude}&result_type=country&key=${process.env.geolocation_api}`);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
res.json(data);
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize database and start app
|
// Initialize database and start app
|
||||||
initDatabase().then(() => {
|
initDatabase().then(() => {
|
||||||
|
|||||||
+32
-34
@@ -354,6 +354,27 @@
|
|||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/chalk/node_modules/has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/chalk/node_modules/supports-color": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/chokidar": {
|
"node_modules/chokidar": {
|
||||||
"version": "3.6.0",
|
"version": "3.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
|
||||||
@@ -528,7 +549,6 @@
|
|||||||
"version": "16.5.0",
|
"version": "16.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
|
||||||
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
|
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
|
||||||
"license": "BSD-2-Clause",
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@@ -560,7 +580,6 @@
|
|||||||
"version": "3.1.10",
|
"version": "3.1.10",
|
||||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
|
||||||
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
|
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
|
||||||
"license": "Apache-2.0",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jake": "^10.8.5"
|
"jake": "^10.8.5"
|
||||||
},
|
},
|
||||||
@@ -950,12 +969,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/has-flag": {
|
"node_modules/has-flag": {
|
||||||
"version": "4.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/has-symbols": {
|
"node_modules/has-symbols": {
|
||||||
@@ -1459,29 +1479,6 @@
|
|||||||
"url": "https://opencollective.com/nodemon"
|
"url": "https://opencollective.com/nodemon"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemon/node_modules/has-flag": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/nodemon/node_modules/supports-color": {
|
|
||||||
"version": "5.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
|
||||||
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"has-flag": "^3.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/nopt": {
|
"node_modules/nopt": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
|
||||||
@@ -1979,15 +1976,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
"version": "7.2.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"has-flag": "^4.0.0"
|
"has-flag": "^3.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar": {
|
"node_modules/tar": {
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ module.exports = (users) => {
|
|||||||
return res.redirect("/login");
|
return res.redirect("/login");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("User logged in successfully");
|
|
||||||
console.log("User email: " + req.body.email);
|
|
||||||
req.session.authenticated = true;
|
req.session.authenticated = true;
|
||||||
req.session.email = req.body.email;
|
req.session.email = req.body.email;
|
||||||
req.session.errMessage = "";
|
req.session.errMessage = "";
|
||||||
@@ -52,7 +50,7 @@ module.exports = (users) => {
|
|||||||
router.post("/signup", async (req, res) => {
|
router.post("/signup", async (req, res) => {
|
||||||
const userSchema = joi.object({
|
const userSchema = joi.object({
|
||||||
email: joi.string().email().required(),
|
email: joi.string().email().required(),
|
||||||
// name: joi.string().alphanum().max(20).required(),
|
name: joi.string().alphanum().max(20).required(),
|
||||||
password: joi.string().max(20).min(8).required(),
|
password: joi.string().max(20).min(8).required(),
|
||||||
repassword: joi.string().max(20).min(8).required(),
|
repassword: joi.string().max(20).min(8).required(),
|
||||||
});
|
});
|
||||||
@@ -75,21 +73,20 @@ module.exports = (users) => {
|
|||||||
|
|
||||||
users.insertOne({
|
users.insertOne({
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
// name: req.body.name,
|
name: req.body.name,
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
}).then((results, err) => {
|
}).then((results, err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(status.InternalServerError);
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return res.send("Internal server error");
|
res.session.errMessage = "Internal server error";
|
||||||
|
return res.status(status.InternalServerError).redirect("/signup");
|
||||||
}
|
}
|
||||||
|
|
||||||
req.session.authenticated = true;
|
req.session.authenticated = true;
|
||||||
req.session.email = req.body.email;
|
req.session.email = req.body.email;
|
||||||
|
|
||||||
req.session.errMessage = "";
|
req.session.errMessage = "";
|
||||||
res.status(status.Ok);
|
return res.status(status.Ok).redirect("/home");
|
||||||
return res.redirect("/home");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
function getLocation() {
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
navigator.geolocation.getCurrentPosition(success, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function success(position) {
|
||||||
|
const { latitude, longitude } = position.coords;
|
||||||
|
|
||||||
|
fetch("api/location" , {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ latitude, longitude })
|
||||||
|
}).then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log(data.results[0].formatted_address);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function error(err) {
|
||||||
|
console.error("Geolocation error: ", err);
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* lockAccount resets inputs and disabled inputs
|
||||||
|
*/
|
||||||
|
function lockAccount() {
|
||||||
|
// Clear unsaved inputs on page load (refresh doesnt clear them)
|
||||||
|
document.getElementById("account-form").reset();
|
||||||
|
|
||||||
|
document.getElementById("save-account").disabled = true;
|
||||||
|
document.getElementById("email").disabled = true;
|
||||||
|
document.getElementById("name").disabled = true;
|
||||||
|
document.getElementById("password").disabled = true;
|
||||||
|
document.getElementById("repassword").disabled = true;
|
||||||
|
document.getElementById("save-account").classList.add("cursor-not-allowed");
|
||||||
|
|
||||||
|
document.getElementById("edit-account").innerHTML = "Edit";
|
||||||
|
document.getElementById("edit-account").onclick = unlockAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lockPersonal resets inputs and disabled inputs
|
||||||
|
*/
|
||||||
|
function lockPersonal() {
|
||||||
|
// Clear unsaved inputs on page load (refresh doesnt clear them)
|
||||||
|
document.getElementById("personal-form").reset();
|
||||||
|
|
||||||
|
document.getElementById("save-personal").disabled = true;
|
||||||
|
document.getElementById("dob").disabled = true;
|
||||||
|
document.getElementById("education").disabled = true;
|
||||||
|
document.getElementById("ms-single").disabled = true;
|
||||||
|
document.getElementById("ms-married").disabled = true;
|
||||||
|
document.getElementById("ms-divorced").disabled = true;
|
||||||
|
document.getElementById("ms-widowed").disabled = true;
|
||||||
|
document.getElementById("save-personal").classList.add("cursor-not-allowed");
|
||||||
|
|
||||||
|
document.getElementById("edit-personal").innerHTML = "Edit";
|
||||||
|
document.getElementById("edit-personal").onclick = unlockPersonal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unlockAccount removes disabled from inputs and
|
||||||
|
* allows users to edit their profile.
|
||||||
|
*/
|
||||||
|
function unlockAccount() {
|
||||||
|
document.getElementById("save-account").disabled = false;
|
||||||
|
// document.getElementById("email").disabled = false;
|
||||||
|
document.getElementById("name").disabled = false;
|
||||||
|
document.getElementById("password").disabled = false;
|
||||||
|
document.getElementById("repassword").disabled = false;
|
||||||
|
document.getElementById("save-account").classList.remove("cursor-not-allowed");
|
||||||
|
|
||||||
|
document.getElementById("edit-account").innerHTML = "Cancel changes";
|
||||||
|
document.getElementById("edit-account").onclick = lockAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unlocPersonal removes disabled from inputs and
|
||||||
|
* allows users to edit their personal information.
|
||||||
|
*/
|
||||||
|
function unlockPersonal() {
|
||||||
|
document.getElementById("save-personal").disabled = false;
|
||||||
|
document.getElementById("dob").disabled = false;
|
||||||
|
document.getElementById("education").disabled = false;
|
||||||
|
document.getElementById("ms-single").disabled = false;
|
||||||
|
document.getElementById("ms-married").disabled = false;
|
||||||
|
document.getElementById("ms-divorced").disabled = false;
|
||||||
|
document.getElementById("ms-widowed").disabled = false;
|
||||||
|
document.getElementById("save-personal").classList.remove("cursor-not-allowed");
|
||||||
|
|
||||||
|
document.getElementById("edit-personal").innerHTML = "Cancel changes";
|
||||||
|
document.getElementById("edit-personal").onclick = lockPersonal;
|
||||||
|
}
|
||||||
|
|
||||||
|
// On page load, ensure forms are locked and reset
|
||||||
|
lockAccount();
|
||||||
|
// lockPersonal();
|
||||||
+56
-3
@@ -1,5 +1,7 @@
|
|||||||
const status = require("../util/statuses");
|
const status = require("../util/statuses");
|
||||||
|
const bcrypt = require('bcrypt');
|
||||||
const joi = require("joi");
|
const joi = require("joi");
|
||||||
|
const salt = 12;
|
||||||
|
|
||||||
module.exports = (middleware, users) => {
|
module.exports = (middleware, users) => {
|
||||||
const router = require("express").Router();
|
const router = require("express").Router();
|
||||||
@@ -27,7 +29,7 @@ module.exports = (middleware, users) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get('/profile', (req, res) => {
|
router.get('/profile', (req, res) => {
|
||||||
res.render('profiles', { user: req.user });
|
res.render('profile', { user: req.user, errMessage: req.session.errMessage });
|
||||||
return res.status(status.Ok);
|
return res.status(status.Ok);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -43,8 +45,6 @@ module.exports = (middleware, users) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post('/questionnaire', (req, res) => {
|
router.post('/questionnaire', (req, res) => {
|
||||||
console.log("Questionnaire POST body:", req.body);
|
|
||||||
|
|
||||||
const questionnaireSchema = joi.object({
|
const questionnaireSchema = joi.object({
|
||||||
dob: joi.date().required(),
|
dob: joi.date().required(),
|
||||||
education: joi.string().valid('primary', 'secondary', 'tertiary', 'postgraduate').required(),
|
education: joi.string().valid('primary', 'secondary', 'tertiary', 'postgraduate').required(),
|
||||||
@@ -108,5 +108,58 @@ module.exports = (middleware, users) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post("/updateAccount", async (req, res) => {
|
||||||
|
const accountSchema = joi.object({
|
||||||
|
email: joi.string().email(),
|
||||||
|
name: joi.string().alphanum().max(20),
|
||||||
|
password: joi.string().max(20).min(8),
|
||||||
|
repassword: joi.string().max(20).min(8),
|
||||||
|
});
|
||||||
|
|
||||||
|
const valid = accountSchema.validate(req.body);
|
||||||
|
|
||||||
|
if (valid.err) {
|
||||||
|
req.session.errMessage = "Invalid input",
|
||||||
|
res.status(status.BadRequest);
|
||||||
|
return res.redirect("/profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
let update = {
|
||||||
|
// email: req.body.email,
|
||||||
|
name: req.body.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((req.body.password != "") && (req.body.password != req.body.repassword)) {
|
||||||
|
req.session.errMessage = "New passwords must match";
|
||||||
|
res.status(status.BadRequest);
|
||||||
|
return res.redirect("/profile");
|
||||||
|
} else if (req.body.password != "") {
|
||||||
|
let hashedPassword = await bcrypt.hashSync(req.body.password, salt);
|
||||||
|
update.password = hashedPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
users.updateOne(
|
||||||
|
{ email: req.session.email },
|
||||||
|
{ $set: update }
|
||||||
|
).then((result) => {
|
||||||
|
if (result.matchedCount === 0) {
|
||||||
|
console.log(`User not found during account update: ${req.session.email}`);
|
||||||
|
req.session.errMessage = "User session invalid. Please log in again.";
|
||||||
|
res.status(status.NotFound).redirect("/login");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (result.modifiedCount === 0 && result.matchedCount === 1) {
|
||||||
|
console.log(`User account data unchanged (already up-to-date): ${req.session.email}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
req.session.errMessage = "";
|
||||||
|
return res.status(status.Ok).redirect("/profile");
|
||||||
|
}).catch(err => {
|
||||||
|
console.error("Error updating account in database:", err);
|
||||||
|
req.session.errMessage = "An error occurred while saving your information. Please try again.";
|
||||||
|
return res.status(status.InternalServerError).redirect("/profile");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
<%- include("./partials/fileHeader") %>
|
|
||||||
<%- include("./partials/header") %>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<!-- Buttons -->
|
|
||||||
<div class="flex justify-end gap-4 px-5 py-6">
|
|
||||||
<button class="cursor-pointer min-w-[150px] bg-green-600 px-4 py-2 text-white rounded hover:bg-green-800" type="button">
|
|
||||||
Add Asset
|
|
||||||
</button>
|
|
||||||
<button class="cursor-pointer min-w-[150px] bg-green-600 px-4 py-2 text-white rounded hover:bg-green-800" type="button">
|
|
||||||
Create new plan
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<!--This is the cards for plans and other things-->
|
|
||||||
<div class="mt-12">
|
|
||||||
<div class="mb-12 grid gap-y-10 gap-x-6 md:grid-cols-2 mr-3 ml-3 xl:grid-cols-4">
|
|
||||||
<!--box to put logo icon if we want on in a box-->
|
|
||||||
<div class=" relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
|
|
||||||
<!-- <div -->
|
|
||||||
<!-- class="bg-clip-border mx-4 rounded-xl overflow-hidden bg-gradient-to-tr from-blue-600 to-blue-400 text-white shadow-blue-500/40 shadow-lg absolute mt-2 grid h-16 w-16 place-items-center"> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<div class="p-4 flex items-center justify-between">
|
|
||||||
<p class="font-sans text-2xl leading-normal font-normal text-blue-gray-600">
|
|
||||||
Retirement goal</p>
|
|
||||||
<h4
|
|
||||||
class="block text-right antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900">
|
|
||||||
$53k</h4>
|
|
||||||
</div>
|
|
||||||
<div class="border-t border-blue-gray-50 p-10">
|
|
||||||
<p class=" antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600">
|
|
||||||
<strong class="text-green-500">Make this percent bar or graph or something </strong> than last
|
|
||||||
week
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
|
|
||||||
<div class="p-4 flex items-center justify-between">
|
|
||||||
<p class="font-sans text-2xl leading-normal font-normal text-blue-gray-600">
|
|
||||||
Retirement goal</p>
|
|
||||||
<h4
|
|
||||||
class="block text-right antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900">
|
|
||||||
$53k</h4>
|
|
||||||
</div>
|
|
||||||
<div class="border-t border-blue-gray-50 p-10">
|
|
||||||
<p class=" antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600">
|
|
||||||
<strong class="text-green-500">Make this percent bar or graph or something </strong> than last
|
|
||||||
week
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
|
|
||||||
<!-- <div -->
|
|
||||||
<!-- class="bg-clip-border mx-4 rounded-xl overflow-hidden bg-gradient-to-tr from-green-600 to-green-400 text-white shadow-green-500/40 shadow-lg absolute -mt-4 grid h-16 w-16 place-items-center"> -->
|
|
||||||
<!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" -->
|
|
||||||
<!-- class="w-6 h-6 text-white"> -->
|
|
||||||
<!-- <path -->
|
|
||||||
<!-- d="M6.25 6.375a4.125 4.125 0 118.25 0 4.125 4.125 0 01-8.25 0zM3.25 19.125a7.125 7.125 0 0114.25 0v.003l-.001.119a.75.75 0 01-.363.63 13.067 13.067 0 01-6.761 1.873c-2.472 0-4.786-.684-6.76-1.873a.75.75 0 01-.364-.63l-.001-.122zM19.75 7.5a.75.75 0 00-1.5 0v2.25H16a.75.75 0 000 1.5h2.25v2.25a.75.75 0 001.5 0v-2.25H22a.75.75 0 000-1.5h-2.25V7.5z"> -->
|
|
||||||
<!-- </path> -->
|
|
||||||
<!-- </svg> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<!-- we can use this later if needed not sure what it shoudl be for right now. -->
|
|
||||||
<!-- <div class="p-4 text-right"> -->
|
|
||||||
<!-- <p class="block antialiased font-sans text-sm leading-normal font-normal text-blue-gray-600">New Clients -->
|
|
||||||
<!-- </p> -->
|
|
||||||
<!-- <h4 -->
|
|
||||||
<!-- class="block antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900"> -->
|
|
||||||
<!-- 3,462</h4> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<!-- <div class="border-t border-blue-gray-50 p-4"> -->
|
|
||||||
<!-- <p class="block antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600"> -->
|
|
||||||
<!-- <strong class="text-red-500">-2%</strong> than yesterday -->
|
|
||||||
<!-- </p> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
|
|
||||||
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
|
|
||||||
<div class="p-4 flex items-center justify-between">
|
|
||||||
<p class="font-sans text-2xl leading-normal font-normal text-blue-gray-600">
|
|
||||||
Retirement goal</p>
|
|
||||||
<h4
|
|
||||||
class="block text-right antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900">
|
|
||||||
$53k</h4>
|
|
||||||
</div>
|
|
||||||
<div class="border-t border-blue-gray-50 p-10">
|
|
||||||
<p class=" antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600">
|
|
||||||
<strong class="text-green-500">Make this percent bar or graph or something </strong> than last
|
|
||||||
week
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="text-blue-gray-600">
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<%- include("./partials/navBar") %>
|
|
||||||
<%- include("./partials/footer") %>
|
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<%- include("./partials/header") %>
|
<%- include("./partials/header") %>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
<%- include("./partials/header") %>
|
||||||
Welcome: <%= user.email %>
|
Welcome: <%= user.email %>
|
||||||
The Dashboard Page
|
The Dashboard Page
|
||||||
<% if(user.authenticated) { %>
|
<% if(user.authenticated) { %>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<%- include("./partials/fileHeader") %>
|
||||||
|
<%- include("./partials/header") %>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
The Index Page
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<%- include("./partials/navBar") %>
|
||||||
|
<%- include("./partials/footer") %>
|
||||||
+3
-3
@@ -4,18 +4,18 @@
|
|||||||
<div class="flex justify-center items-center h-screen">
|
<div class="flex justify-center items-center h-screen">
|
||||||
<form action="/login" method="POST">
|
<form action="/login" method="POST">
|
||||||
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
|
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
|
||||||
<h1 class="text-3xl block text-center font-semibold">Login</h1>
|
<h1 class="text-3xl block text-center font-semibold"> Login </h1>
|
||||||
<hr class="mt-3">
|
<hr class="mt-3">
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<label for="email" class="block text-base mb-2">Email</label>
|
<label for="email" class="block text-base mb-2">Email</label>
|
||||||
<input type="text" id="email" name="email"
|
<input type="text" id="email" name="email"
|
||||||
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||||
placeholder="Enter Email" />
|
placeholder="Enter Email" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<label for="password" class="block text-base mb-2">Password</label>
|
<label for="password" class="block text-base mb-2">Password</label>
|
||||||
<input type="password" id="password" name="password"
|
<input type="password" id="password" name="password"
|
||||||
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||||
placeholder="Enter Password" />
|
placeholder="Enter Password" />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-red-800 font-bold" id="forgor"> <%= errMessage %></div>
|
<div class="text-red-800 font-bold" id="forgor"> <%= errMessage %></div>
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
<script src="/static/scripts/geolocation.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<%- include("./partials/fileHeader") %>
|
||||||
|
<%- include("./partials/header") %>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h2 class="ml-11 mt-5 mb-6 text-xl font-semibold mb-4 text-white">Welcome <%= user.name %></h2>
|
||||||
|
|
||||||
|
<% if (errMessage != "") { %>
|
||||||
|
<div class="max-w-md mx-auto mb-10 rounded-lg shadow-md text-white font-bold bg-red-400 py-4 text-center"><%= errMessage %></div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<div class="max-w-md mx-auto bg-white p-8 mb-10 rounded-lg shadow-md">
|
||||||
|
<div class="flex flex-row justify-between">
|
||||||
|
<h3 class="pt-2 pr-2 pb-2">Account settings</h3>
|
||||||
|
<button id="edit-account" onclick="unlockAccount()" class="py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Edit</button>
|
||||||
|
</div>
|
||||||
|
<form action="/updateAccount" method="post" class="space-y-4 mt-4" id="account-form">
|
||||||
|
|
||||||
|
<label for="email" class="block text-sm font-medium text-gray-700">Email</label>
|
||||||
|
<input id="email" disabled type="text" name="email" value="<%= user.email %>" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
|
||||||
|
<label for="name" class="block text-sm font-medium text-gray-700">Name</label>
|
||||||
|
<input id="name" disabled type="text" name="name" value="<%= user.name %>" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
|
||||||
|
<label for="password" class="block text-sm font-medium text-gray-700">New password</label>
|
||||||
|
<input id="password" disabled type="password" name="password" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
|
||||||
|
<label for="repassword" class="block text-sm font-medium text-gray-700">Confirm new password</label>
|
||||||
|
<input id="repassword" disabled type="password" name="repassword" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button id="save-account" disabled type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-not-allowed">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!--
|
||||||
|
<div class="mb-10 max-w-md mx-auto bg-white p-8 rounded-lg shadow-md">
|
||||||
|
<div class="flex flex-row justify-between">
|
||||||
|
<h3 class="pt-2 pr-2 pb-2">Personal information</h3>
|
||||||
|
<button onclick="unlockPersonal()" class="py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Edit</button>
|
||||||
|
</div>
|
||||||
|
<form action="/updatePersonal" method="post" class="space-y-4" id="personal-form">
|
||||||
|
<div>
|
||||||
|
<label for="dob" class="block text-sm font-medium text-gray-700">Date of Birth</label>
|
||||||
|
<input id="dob" disabled type="date" name="dob" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="education" class="block text-sm font-medium text-gray-700">Education</label>
|
||||||
|
<select disabled name="education" id="education" class="mt-1 block w-full px-3 py-2 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
<option value="primary">Primary (Elementary)</option>
|
||||||
|
<option value="secondary">Secondary (High School)</option>
|
||||||
|
<option value="tertiary">Tertiary (College/University)</option>
|
||||||
|
<option value="postgraduate">Postgraduate (Master's/PhD)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700">Marital Status</label>
|
||||||
|
<div class="mt-1 space-x-4">
|
||||||
|
<label class="inline-flex items-center">
|
||||||
|
<input disabled id="ms-single" type="radio" name="maritalStatus" value="single" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
<span class="ml-2 text-sm text-gray-700">Single</span>
|
||||||
|
</label>
|
||||||
|
<label class="inline-flex items-center">
|
||||||
|
<input disabled id="ms-married" type="radio" name="maritalStatus" value="married" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
<span class="ml-2 text-sm text-gray-700">Married</span>
|
||||||
|
</label>
|
||||||
|
<label class="inline-flex items-center">
|
||||||
|
<input disabled id="ms-divorced" type="radio" name="maritalStatus" value="divorced" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
<span class="ml-2 text-sm text-gray-700">Divorced</span>
|
||||||
|
</label>
|
||||||
|
<label class="inline-flex items-center">
|
||||||
|
<input disabled id="ms-widowed" type="radio" name="maritalStatus" value="widowed" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||||
|
<span class="ml-2 text-sm text-gray-700">Widowed</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button id="save-personal" disabled type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-not-allowed">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<div class="mt-24"></div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script src="/static/scripts/profile.js"></script>
|
||||||
|
|
||||||
|
<%- include("./partials/navBar") %>
|
||||||
|
<%- include("./partials/footer") %>
|
||||||
+10
-10
@@ -5,28 +5,28 @@
|
|||||||
<div class="flex justify-center items-center h-screen">
|
<div class="flex justify-center items-center h-screen">
|
||||||
<form action="/signup" method="POST">
|
<form action="/signup" method="POST">
|
||||||
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
|
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
|
||||||
<h1 class="text-3xl block text-center font-semibold">Signup</h1>
|
<h1 class="text-3xl block text-center font-semibold"> Signup </h1>
|
||||||
<hr class="mt-3">
|
<hr class="mt-3">
|
||||||
<div class="mt-3">
|
|
||||||
<label for="name" class="block text-base mb-2">Name</label>
|
|
||||||
<input type="text" id="name" name="name"
|
|
||||||
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
|
||||||
placeholder="Enter Name" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<label for="email" class="block text-base mb-2">Email</label>
|
<label for="email" class="block text-base mb-2">Email</label>
|
||||||
<input type="text" id="email" name="email"
|
<input type="text" id="email" name="email"
|
||||||
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||||
placeholder="Enter Email" />
|
placeholder="Enter Email" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-3">
|
||||||
|
<label for="name" class="block text-base mb-2">Name</label>
|
||||||
|
<input type="text" id="name" name="name"
|
||||||
|
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||||
|
placeholder="Enter Name" />
|
||||||
|
</div>
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<label for="password" class="block text-base mb-2">Password</label>
|
<label for="password" class="block text-base mb-2">Password</label>
|
||||||
<input type="password" id="password" name="password"
|
<input type="password" id="password" name="password"
|
||||||
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||||
placeholder="Enter Password" />
|
placeholder="Enter Password" />
|
||||||
<label for="password" class="block text-base mb-2 mt-3">Re-type Password</label>
|
<label for="password" class="block text-base mb-2 mt-3">Re-type Password</label>
|
||||||
<input type="password" id="repassword" name="repassword"
|
<input type="password" id="repassword" name="repassword"
|
||||||
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||||
placeholder="Enter Password" />
|
placeholder="Enter Password" />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-red-800 font-bold " id="forgor"> <%= errMessage %></div>
|
<div class="text-red-800 font-bold " id="forgor"> <%= errMessage %></div>
|
||||||
|
|||||||
Reference in new issue
Block a user