Users management in node js with express, mongodb as server database [closed]

自古美人都是妖i 提交于 2020-01-14 08:59:11

问题


Looking for the way to add user management to my site.

Site: Working with Node.js & Express, when creating the initial project with Express, the app.js file contains these lines:

app.use('/', routes);
app.use('/users', users);

In addition, a file users.js is created under routes folder. My question is how to manage users, force login, and show different views for regular user / admin user. I wish to find a simple example / tutorial.

Storage: Working with MongoDB & mongoose, I noticed the database has Users folder built-in. I want to save users data (user + password + preference) on MongoDB. What is the way to do this?


回答1:


I followed this tutorial. https://scotch.io/tutorials/easy-node-authentication-setup-and-local

Passport js does the job very nicely, doing this without a library would just require you to reinvent the wheel.



来源:https://stackoverflow.com/questions/27291137/users-management-in-node-js-with-express-mongodb-as-server-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!