Uuuuuh welcome welcome welcome, I see you passed the first test... not too bad ๐
Okay so: this repo is the base for your mistery app. ONE member of the team should fork and clone it, and then, start working.
You will be doing pair programming: but that DOESN'T MEAN that only one of you has to do the all the work. All group members will be asked questions about the code, so you all better understand what's going on in the code presented.
โณ Hurry up, you don't have much time!
This boilerplate already has every npm package you need installed, you just need to run:
npm install
Once it's finished, to make sure everything is okay, run:
npm run dev
If it is... the challenge begins.
- Create a model for
User
. Users should have the following fields: name (string), age (number), email (string), hashedPassword (string). - Users should be able to signup, login & logout, so you will have to create the routes and views that are necessary for it. When you create the file
routes/auth.js
, remember to import it on the theapp.js
file for it to work. - Remember to add links in the navbar of the app to these routes to access them easily.
You already have the packages installed and everything configured in the app.js
, you just need to work on the routes & views part of authentication.
- Create a new routes file called
routes/enigma.js
. Remember to import it on the theapp.js
file for it to work. Create a protected route to localhost:3000/enigmas: only logged in users should be able to see this route. If a user tries to access this route without being authenticated, the route should redirect them to the login page.
You already have a middleware for this in the middlewares
folder. Make sure that the auth route for the login is correct and is the same in your app. If it isn't, write the right route to the login page:
module.exports = isLoggedIn = (req, res, next) => {
if (!req.session.currentUser) {
// Change this line with your login route if it is different
return res.redirect('/auth/login');
}
next();
};
Remember that you can use the middleware this way:
const isLoggedIn = require('../middlewares');
router.get('/enigmas', isLoggedIn, async (req, res, next) => {
// ...
})
Create a user for each member of your team.
When you are finished, make sure to commit all changes and then come see us for validation and the NEXT CLUE OF THE CHALLENGE.