This project is a complete authentication system built using Node.js, Express, and MongoDB, designed as a starter code for creating any new application. It includes functionalities like email sign up, sign in, sign out, password reset, and Google social authentication. The system also includes extra features such as forgot password and reCAPTCHA for enhanced security.
- Email Sign Up
- Email Sign In
- Sign Out
- Password Reset after Sign In
- Password encryption stored in the database
- Google Login/Sign Up (Social Authentication)
- Forgot Password (with reset link or random password sent via email)
- Notifications for:
- Unmatching passwords during sign up
- Incorrect password during sign in
- reCAPTCHA on both sign up and log in pages (Extra Points)
- Sending emails using parallel jobs (Super Extra Points)
- Node.js installed
- MongoDB installed and running
- Google OAuth credentials
- Clone the repository:
git clone [https://github.com/your-username/your-repo.git](https://github.com/ajitkumarpal1/autWithFruntEnd)
- Navigate to the project directory:
cd your-repo
- Install the dependencies:
npm install
- Set up environment variables:
- Create a
.env
file in the root directory. - Add the following variables with your configuration:
PORT=3000 MONGO_URI=your_mongo_db_uri SESSION_SECRET=your_session_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret EMAIL_HOST=your_email_host EMAIL_PORT=your_email_port EMAIL_USER=your_email_user EMAIL_PASS=your_email_password
- Create a
- Start the server:
npm start
- Open your browser and navigate to
http://localhost:9000
.
- config: Contains configuration files for database connections, passport strategies, etc.
- controllers: Handles the logic for different routes and user interactions.
- middlewares: Contains middleware functions for authentication, validation, etc.
- models: Defines the database schemas using Mongoose.
- routes: Defines the application routes and links them to the appropriate controllers.
- utils: Utility functions and helpers.
- views: EJS templates for rendering HTML pages.
- Page:
user_sign_up.ejs
- Validates and creates a new user with encrypted password.
- Displays notifications for unmatching passwords.
- Page:
user_sign_in.ejs
- Authenticates the user and redirects to home page.
- Displays notifications for incorrect password.
- Signs the user out and redirects to sign in page.
- Allows authenticated users to reset their password.
- Encrypts the new password and updates in the database.
- Uses Passport.js for Google OAuth authentication.
- Page:
forgoten_password.ejs
- Sends a reset password link via email which expires after a certain time.
- Implemented reCAPTCHA for additional security on sign up and sign in pages.
- Sending emails using parallel jobs to improve performance.
- Ensure all environment variables are set correctly.
- Deploy the application on a platform like Heroku, AWS, or any other cloud provider.
This project is licensed under the MIT License - see the LICENSE file for details.
For any inquiries or feedback, please contact [[email protected]].