Skip to content

Express authentication and authorization with JwtToken skeleton using passport, mongodb and bcrypt.

License

Notifications You must be signed in to change notification settings

Petrakus/express-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-auth

Express authentication and authorization skeleton using passport, mongodb and bcrypt.

Getting started

First you need to have npm and Node.js installed. To install project dependencies use:

npm install

To start the server use:

npm start

*Note that if you have set the ENV variable PORT server will use the port that you set there. Otherwise server will be started at port: 3001

Endpoints

/api/auth/register - User registration. Method: POST

Request:

{
	"name":"Test",
	"email":"test@example.com",
	"password":"1234"
}

Response:

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YTBlYTJjZmIwNzc0ODIwNjA0MjZmMDUiLCJpYXQiOjE1MTA5MDg2MjMsImV4cCI6MTUxMDk5NTAyM30.X5XDB6_m1R9P87ErslknRs1qP6gVV815HyPLPRrKP8s"
}

/api/auth/login - User login. Method: POST

Request:

{
	"email":"test@example.com",
	"password":"1234"
}

Response:

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YTBlYTJjZmIwNzc0ODIwNjA0MjZmMDUiLCJpYXQiOjE1MTA5MDg2MjMsImV4cCI6MTUxMDk5NTAyM30.X5XDB6_m1R9P87ErslknRs1qP6gVV815HyPLPRrKP8s"
}

/api/auth/me - User details. Method: GET

Request:

Header:
authorization: <token>

Response:

{
    "_id": "5a0ea2cfb077482060426f05",
    "name": "Test",
    "email": "test@example.com",
    "password": null,
    "__v": 0
}

Built With

Authors

  • Petar Petrov - Initial work - Petrakus

See also the list of contributors who participated in this project.

About

Express authentication and authorization with JwtToken skeleton using passport, mongodb and bcrypt.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published