Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jwt authentication backend #149

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions Node-JS-Projects/Intermediate/JWT-Authenticator-With-Roles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<h1 align='center'><b>💥 JWT-Authenticator-With-Roles 💥</b></h1>

<div align='center' style='display: flex; justify-content: center; gap: 1rem'>

![Nodemon](https://img.shields.io/badge/NODEMON-%23323330.svg?style=for-the-badge&logo=nodemon&logoColor=%BBDEAD)

![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB)

![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)

![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge&logo=mongodb&logoColor=white)

</div>

![Line](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/114330097/4b78510f-a941-45f8-a9d5-80ed0705e847)


## Description 📃

<div>
<p>This api helps user to get a modern starting project for production use. This is a standard setup for any production level project. The different files are used to handle different functions. You can clone it to get started on your project quickly.

This readme file provides all the details you need to run and use this project.</p>
</div>


## How to run it? 🕹️

- Clone the repository
- Run `npm install`
- Create a `.env` file and add the following variables
- `PORT`
- `ACCESS_TOKEN_SECRET`
- `REFRESH_TOKEN_SECRET`
- `ACCESS_TOKEN_EXPIRY`
- `REFRESH_TOKEN_EXPIRY`
- `BCRYPT_SALT`
- `MONGODB_URI`
- `CORS_ORIGIN`
- Run `npm run dev` or `npm start`



## Features

- **User Authentication**

- Register
- Login
- Logout
- Refresh Token

- **User Roles**
- Admin
- User

## Screenshots of Endpoints

**POST `api/v1/user/register`**

![alt text](images/image.png)

**POST `api/v1/user/register-admin`**

![alt text](images/register_admin.png)

**POST `api/v1/user/login`**

![alt text](images/image-1.png)

**POST `api/v1/user/logout`**

![alt text](images/logout.png)

**POST `api/v1/user/refresh-token`**

![alt text](images/refresh.png)

**GET `api/v1/user/i-am-user`**

![alt text](images/protectedUser.png)

**GET `api/v1/user/i-am-admin`**

![alt text](images/protected_admin.png)

![Line](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/114330097/4b78510f-a941-45f8-a9d5-80ed0705e847)

<h4 align='center'>Developed By <b><i>PULKIT GUPTA</i></b> 👦</h4>
<p align='center'>
<a href='https://www.linkedin.com/in/pulkit-gupta-b16a721ba'>
<img src='https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white' />
</a>
<a href='https://github.com/Pulkit95700'>
<img src='https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white' />
</a>
</p>

<h4 align='center'>Happy Coding 🧑‍💻</h4>

<h3 align="center">Show some &nbsp;❤️&nbsp; by &nbsp;🌟&nbsp; this repository!</h3>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading