Now that we have our views and layouts all set, we want to be able to register a user. So we have our form and if we open up routes/users
, you can see we have a couple of requests but we have all get requests. We need a post request to user/register
. So I'll copy the route.get
method and I'll change get
to post
, and let's get rid of res.render
:
router.get('/register', function(req, res, next) { res.render('register',{title: 'Register'}); }); router.get('/login', function(req, res, next) { res.render('login',{title: 'Login'}); }); router.post('/register', function(req, res, next){ });
Now it's really important to understand that when we submit a form and we can grab the data using req.body.email
. We usually do that using body-parser
, which we have installed and set up, but body-parser
cannot handle file uploads and we have the profile image upload, that's where multer
comes in. If we look at our app.js
file, you can see we have this, and we'll set our...