A log-in system backend built with node.js and MongoDB (Support Sign up, Sign in, Log out, verify token/session).
- Npm
- NodeJS
- MongoDB
- Add your own MongoDB infomation in
app.jsto make the database work. - In root directory, run
npm install - start your server
node server.js
- sign up
- function: store the user's registration info into the database.
- METHOD: POST
- Request URL:
/account/signup - post data :
{ "password": "passwordtest", "email": "test1@gmail.com", "firstName":"test1_firstname", "lastName":"test1_lastname" }- server response :
{success: true, message:'sign up!}' when signUp success
- sign in
- function: check if the email and password users entered are consistent with records from database.
- METHOD: POST
- post data :
/account/signin
{ "password": "passwordtest", "email": "test1@gmail.com" }- server response (when sign in success) :
{ "success": "true", "message":'valid sign in!', "token": "<a token id>" } - verify token/session
- function: veryfy if the token is consistent with record form database and it's not deleted(log out) .
- Request URL:
/account/verify?=<token id> - METHOD: GET
- server response(when verify success):
{ "success": "true", "message":'good', } - Log out
- function: log out from system
- Request URL:
/account/logout?=<token id> - METHOD: GET
- server response(when log out success):
{ "success": "true", "message":'log out successfully', }
- Tutorial about creating REST API by Academind
- Turorial about building log-in system by Keith, the Coder