{"id":24634542,"url":"https://github.com/aman1-2/authentication-application-backend","last_synced_at":"2026-04-14T05:34:36.256Z","repository":{"id":238099724,"uuid":"795869361","full_name":"aman1-2/Authentication-Application-Backend","owner":"aman1-2","description":"This Node.js project offers robust user authentication and authorization functionalities for web applications. It includes features such as user registration, login, JWT-based authentication, and role-based access control. Utilizing Express.js and MongoDB, the project ensures secure password handling through bcrypt hashing and implements middleware","archived":false,"fork":false,"pushed_at":"2024-05-04T10:36:53.000Z","size":998,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T09:13:01.821Z","etag":null,"topics":["bcrypt","dotenv","expressjs","javascript","jsonwebtoken","mongodb","mongoose","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aman1-2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-04T09:46:13.000Z","updated_at":"2024-05-04T10:41:03.000Z","dependencies_parsed_at":"2024-05-04T10:44:42.890Z","dependency_job_id":null,"html_url":"https://github.com/aman1-2/Authentication-Application-Backend","commit_stats":null,"previous_names":["aman1-2/authentication-application-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aman1-2%2FAuthentication-Application-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aman1-2%2FAuthentication-Application-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aman1-2%2FAuthentication-Application-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aman1-2%2FAuthentication-Application-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aman1-2","download_url":"https://codeload.github.com/aman1-2/Authentication-Application-Backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244574798,"owners_count":20474818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bcrypt","dotenv","expressjs","javascript","jsonwebtoken","mongodb","mongoose","nodejs"],"created_at":"2025-01-25T09:13:03.964Z","updated_at":"2026-04-14T05:34:36.225Z","avatar_url":"https://github.com/aman1-2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Authentication-Application-Backend\n\n# Project Description\n\n## Need\nIn modern web applications, user authentication and authorization are essential components for ensuring security and controlling access to resources. Implementing a robust authentication system is crucial for protecting sensitive user data and preventing unauthorized access. This project addresses the need for a secure and reliable authentication mechanism by providing a Node.js-based solution with features such as user registration, login, JWT authentication, and role-based authorization.\n\n## Overview\nThis Node.js project implements user authentication and authorization functionalities using Express.js and MongoDB. It provides endpoints for user registration, login, and access control based on user roles.\n\n## Features\n- **User Registration:** Users can register by providing their name, email, password, and role. Passwords are securely hashed before storage.\n- **User Login:** Registered users can log in using their email and password. Upon successful login, a JWT token is generated for authentication.\n- **JWT Authentication:** JSON Web Tokens (JWT) are used for stateless authentication. Tokens are signed with a secret key and verified for each request to protected routes.\n- **Role-Based Authorization:** Middleware functions are implemented to restrict access to certain routes based on user roles (e.g., student, admin).\n- **Secure Password Handling:** User passwords are hashed using bcrypt before storage to ensure security.\n- **Database Connectivity:** The project connects to a MongoDB database using Mongoose for data storage and retrieval.\n\n## Project Structure\n- **Config Folder:** Contains configurations for database connection and environment variables.\n- **Controllers Folder:** Includes controller functions for user registration and login.\n- **Middleware Folder:** Contains middleware functions for authentication and role-based authorization.\n- **Models Folder:** Defines the Mongoose schema for the User model.\n- **Routes Folder:** Defines routes for user authentication and authorization.\n- **Additional Files:**\n  - **.env:** Configuration file for environment variables such as the port number, database URL, and JWT secret key.\n  - **index.js:** Main entry point of the application, sets up the Express server, defines routes, and establishes a database connection.\n\n## Usage\n1. Ensure MongoDB is installed and running.\n2. Create a `.env` file with configuration variables.\n3. Run `npm install` to install dependencies.\n4. Start the server with `npm start`.\n5. Access the endpoints for user registration, login, and protected routes as defined in the routes.\n\n## Dependencies\n- **Express:** Web application framework for Node.js.\n- **Mongoose:** MongoDB object modeling tool for Node.js.\n- **bcrypt:** Library for hashing passwords securely.\n- **jsonwebtoken:** Library for generating and verifying JSON Web Tokens.\n- **dotenv:** Library for loading environment variables from a `.env` file.\n\n## Conclusion\nThis project provides a robust authentication and authorization system for web applications, ensuring secure access control and user management. It can be easily integrated into various applications requiring user authentication functionalities.\n\n## Preview\n**Signup Route -\u003e**\n![\"The signup route\"](./Assets/signup.jpg)\n\u003cbr\u003e\u003cbr\u003e\n\n**Login Route -\u003e**\n![\"The login route\"](./Assets/login.jpg)\n\u003cbr\u003e\u003cbr\u003e\n\n**Fetching Admin details throw a token -\u003e**\n![\"The Admin fecting route\"](./Assets/admin.jpg)\n\u003cbr\u003e\u003cbr\u003e\n\n**Fetching Admin details throw a Bearer token -\u003e**\n![\"The Admin fecting route\"](./Assets/bearer%20token.jpg)\n\u003cbr\u003e\u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faman1-2%2Fauthentication-application-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faman1-2%2Fauthentication-application-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faman1-2%2Fauthentication-application-backend/lists"}