Merge pull request #2 from JoaquinPar/feature/questionnaire
Just a bug fix
This commit is contained in:
8 files changed
+42
-6
No files matched your search
@@ -54,9 +54,12 @@ Example:
|
||||
retirementCalculator/
|
||||
├── src/
|
||||
│ ├── views/
|
||||
| ├── css/
|
||||
| ├── images/
|
||||
| └── scripts/
|
||||
│ │ └── partials/
|
||||
│ ├── css/
|
||||
│ ├── images/
|
||||
│ ├── scripts/
|
||||
│ └── utils/
|
||||
│
|
||||
├── app.js
|
||||
├── .env.example
|
||||
├── .gitignore
|
||||
|
||||
@@ -61,7 +61,7 @@ app.get('/login', (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/home', (req, res) => {
|
||||
res.render('home');
|
||||
res.render('home', { session: req.session });
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
@@ -70,6 +70,16 @@ app.get('/aboutUs', (req, res) => {
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
app.get('/logout', (req, res) => {
|
||||
req.session.destroy();
|
||||
return res.redirect('/login');
|
||||
});
|
||||
|
||||
app.get('/*splat', (req, res) => {
|
||||
res.send('404 Not Found');
|
||||
return res.status(status.NotFound);
|
||||
});
|
||||
|
||||
// Initialize database and start app
|
||||
initDatabase().then(() => {
|
||||
console.log("Successfully connected to MongoDB");
|
||||
|
||||
@@ -70,7 +70,7 @@ module.exports = (users) => {
|
||||
return res.redirect("/signup");
|
||||
}
|
||||
|
||||
let hashedPassword = await bcrypt.hash(req.body.password, salt);
|
||||
let hashedPassword = await bcrypt.hashSync(req.body.password, salt);
|
||||
|
||||
users.insertOne({
|
||||
email: req.body.email,
|
||||
|
||||
@@ -33,5 +33,10 @@ module.exports = (middleware) => {
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/logout', middleware, (req, res) => {
|
||||
req.session.destroy();
|
||||
return res.redirect('/login');
|
||||
});
|
||||
|
||||
return router;
|
||||
};
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<body>
|
||||
<%- include("./partials/header") %>
|
||||
<% if (session.authenticated) { console.log(session.email); } else { console.log("No user"); } %>
|
||||
<main>
|
||||
The Dashboard Page
|
||||
</main>
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
<button type="submit"
|
||||
class="border-2 border-gray-600 bg-blue-600 text-white py-1 w-full rounded-md hover:bg-transparent hover:text-indigo-700 font-semibold">Login</button>
|
||||
</div>
|
||||
<div class="mt-5 block justify-between items-center">
|
||||
<label>Don't have an account?</label>
|
||||
<a href="/signup" class="text-indigo-600 font-semibold">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,16 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="/more" class="block py-2 px-3 lg:p-0 text-gray-900 rounded hover:bg-gray-100 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 dark:text-white lg:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent">More</a>
|
||||
</li>
|
||||
</li>
|
||||
<% if (session.authenticated) { %>
|
||||
<li>
|
||||
<a href="/logout" class="block py-2 px-3 lg:p-0 text-gray-900 rounded hover:bg-gray-100 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 dark:text-white lg:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent">Logout</a>
|
||||
</li>
|
||||
<% } else { %>
|
||||
<li>
|
||||
<a href="/login" class="block py-2 px-3 lg:p-0 text-gray-900 rounded hover:bg-gray-100 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 dark:text-white lg:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent">Login</a>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
<button type="submit"
|
||||
class="border-2 border-gray-600 bg-blue-600 text-white py-1 w-full rounded-md hover:bg-transparent hover:text-indigo-700 font-semibold">Signup</button>
|
||||
</div>
|
||||
<div class="mt-5 block justify-between items-center">
|
||||
<label>Already have an account?</label>
|
||||
<a href="/login" class="text-indigo-600 font-semibold">Login</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user