Reputation: 459
I am writing a login system in Node.js. I am generating password automatically
app.post("/new/user", (req, res,)=>
{
var passwd = generateRandomPasswd();
fs.writeFileSync("credentials.txt", "Username : "+req.body.userName+"\nPassword : "+passwd);
})
How can I send this credential file to the client machine??
Upvotes: 1
Views: 407
Reputation: 829
app.post("/new/user", (req, res,)=>
{
var passwd = generateRandomPasswd();
fs.writeFileSync("credentials.txt", "Username : "+req.body.userName+"\nPassword : "+passwd);
var readStream = fileSystem.createReadStream('credentials.txt');
readStream.pipe(res);
})
Upvotes: 1