Giter Site home page Giter Site logo

auth's Introduction

NodeJS JWT Authentication sample

This is a NodeJS API that supports username and password authentication with JWTs.

Available APIs

User APIs

POST /register

You can do a POST to /register to create a new user.

The body must have:

  • email: The email
  • password: The password

It returns the following:

{
  "message": "Success message Or Error message",
}

The message will depend on the execution if the email already exists, it will be an error message otherwise it will tell you that the registration was successful and that you will have to confirm it with the confirmation email.

POST /login

You can do a POST to /login to log.

The body must have:

  • email: The email
  • password: The password

It returns the following:

{
  "access_token": {jwt},
  "refresh_token": {jwt},
}

GET /verify/:token

You can do a GET to /verify/:token to confirm your registration.

It returns the following:

{
  "access_token": {jwt},
  "refresh_token": {jwt},
  "message": "success message",
}

GET /refreshToken

You can do a GET to /refreshToken to refresh your access token.

The JWT - refresh_token must be sent on the Authorization header as follows: Authorization: Bearer {jwt}

It returns the following:

{
  "access_token": {jwt}
}

Running it

Just clone the repository, run npm install and then node server.js. That's it :).

Issue Reporting

If you have found a bug or if you have a feature request, please contact me.

Author

MAOUCHE Yacine

License

This project is licensed under the MIT license. See the LICENSE file for more info.

auth's People

Contributors

maouche avatar

Stargazers

nameauditor avatar Iss M avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.