Skip to content

Express API authenticated with JWT, using bcrypt for hashing passwords and saving them to a MongoDB datasource

Notifications You must be signed in to change notification settings

ltzenteno/auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup

  1. Clone the repo with git clone https://github.com/ltzenteno/auth-api.git

  2. Install its dependencies with npm install

  3. Create a Mongo Database and replace it's values in your .env file, for this example I'm using the following url:

DB=mongodb://brave:brave@localhost:27017/bravedb
  1. start the server with npm start

  2. create default user executing the following url:

http://localhost:8080/api/setup

(the default user is [email protected] - hola)

Now you can authenticate with the following endpoint:

http://localhost:8080/api/authenticate

You have to send the corresponding email and password, if the credentials are correct, you should see the response with the JWT token.

screen shot 2018-01-08 at 2 13 27 pm

Now, having the token we can call the fetch users endpoint:

http://localhost:8080/api/users

Sending the corresponding token inside the x-access-token header.

screen shot 2018-01-08 at 2 13 32 pm

About

Express API authenticated with JWT, using bcrypt for hashing passwords and saving them to a MongoDB datasource

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published