Advertisement
Guest User

Untitled

a guest
May 5th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const router = express.Router();
  3. const bcrypt = require('bcrypt');
  4. const Users = require('../user');
  5.  
  6. router.get('/', function(req, res, next) {
  7.     res.render('register', { title: 'Express' });
  8. });
  9.  
  10. router.post('/', function(req, res, next) {
  11.     if (req.body.id && req.body.password && req.body.email && req.body.username) {
  12.         const userData = {
  13.             id: req.body.id,
  14.             password: req.body.password,
  15.             email: req.body.email,
  16.             username: req.body.username
  17.         };
  18.         Users.create(userData, (err, user) => {
  19.             if (err)
  20.                 return next(err);
  21.             res.redirect('/');
  22.         });
  23.     }
  24. });
  25.  
  26. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement