Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Adding User And Hashed Password In ExpressJS

var express = require('express');
var router = express.Router();
var bcrypt = require("bcrypt");
const User = require('../models/user'); 

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get("/createuser", async  function(req, res, next) {
  const password = await bcrypt.hash('first', 10);
  
 const user = await User.create({username: 'first', password: password});
 res.json({user: user});
  });
  
 
PREVIOUS NEXT
Tagged: #Adding #User #And #Hashed #Password #In #ExpressJS
ADD COMMENT
Topic
Name
9+2 =