A modern, secure user authentication system built with Node.js, Express, MongoDB Atlas, and Bcrypt for secure password hashing. Features a beautiful, responsive UI and allows users to register, log in, and share secrets anonymously.
π Production URL: https://register-authentication-2.onrender.com
- Node.js - JavaScript runtime environment for backend development
- Express - Web framework for creating the server
- MongoDB Atlas - Cloud NoSQL database to store user data
- Mongoose - ODM library for MongoDB data modeling
- Bcrypt - Library for secure password hashing
- EJS - Template engine for rendering dynamic pages
- Express-Session - Session management for user authentication
- Dotenv - Environment variable management
- Bootstrap - Frontend framework for responsive design
- FontAwesome - Icons library
π¦ register-authentication
βββ π views/ # EJS templates
β βββ π partials/ # Header and footer components
β βββ π home.ejs # Landing page
β βββ π login.ejs # Login page
β βββ π register.ejs # Registration page
β βββ π secrets.ejs # Protected secrets page
β βββ π submit.ejs # Submit secrets page
βββ π public/ # Static files
β βββ π css/
β βββ π styles.css # Custom styles
βββ π app.js # Main server code
βββ π package.json # Project dependencies
βββ π .env # Environment variables (not tracked)
βββ π .gitignore # Git ignore rules
βββ π README.md # Project documentation
git clone https://github.com/abreuclariana/register-authentication
cd register-authenticationnpm installCreate a .env file in the root directory:
# Database Configuration
MONGODB_URI=mongodb://localhost:27017/userDB
# Session Configuration
SESSION_SECRET=your-super-secret-session-key-change-this-in-production
# Server Configuration
PORT=4000
NODE_ENV=development# Create data directory
mkdir C:\data\db
# Start MongoDB
mongod --dbpath C:\data\dbnpm start
# or
node app.jsThe server will be running at http://localhost:4000 π
- Create MongoDB Atlas account: https://cloud.mongodb.com/
- Create cluster: Choose M0 Sandbox (free tier)
- Configure database access: Create user with password
- Configure network access: Allow access from anywhere (0.0.0.0/0)
- Get connection string: Copy the MongoDB Atlas connection string
- Connect GitHub repository to Render
- Add environment variables:
MONGODB_URI=mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/userDB?retryWrites=true&w=majority SESSION_SECRET=your-production-secret-key NODE_ENV=production - Deploy: Render will automatically build and deploy
- User Registration with email validation
- Secure Login with password verification
- Session Management with express-session
- Password Hashing with bcrypt (10 salt rounds)
- Protected Routes with authentication middleware
- Responsive Design with Bootstrap
- Modern UI with gradients and animations
- Error Handling with user-friendly messages
- Success Notifications for user actions
- Mobile-First approach
- MongoDB Atlas cloud database
- User Collection for storing credentials
- Secrets Collection for anonymous secrets
- Data Validation with Mongoose schemas
- Password Hashing with bcrypt
- Session Security with secret keys
- Environment Variables for sensitive data
- Input Validation and sanitization
| Method | Route | Description | Authentication |
|---|---|---|---|
GET |
/ |
Home page with register/login | β Public |
GET |
/login |
Login page | β Public |
GET |
/register |
Registration page | β Public |
POST |
/register |
User registration | β Public |
POST |
/login |
User authentication | β Public |
GET |
/secrets |
Protected secrets page | β Required |
GET |
/submit |
Submit secrets page | β Required |
POST |
/submit |
Submit new secret | β Required |
POST |
/logout |
User logout | β Required |
- Glass Morphism effects on home page
- Gradient Backgrounds for modern look
- Floating Animations for interactive elements
- Responsive Cards with shadows and borders
- Icon Integration with FontAwesome
- Color-coded buttons and alerts
- Intuitive Navigation between pages
- Clear Error Messages in Portuguese/English
- Success Feedback for user actions
- Loading States and transitions
- Mobile Optimization for all devices
- Environment Variables: Sensitive data stored in
.env - Password Hashing: Bcrypt with 10 salt rounds
- Session Management: Secure session configuration
- Input Validation: Server-side validation
- HTTPS: Production deployment with SSL
- Database Security: MongoDB Atlas with authentication
- Efficient Database Queries with Mongoose
- Session Optimization with proper configuration
- Static File Serving with Express
- Error Handling with proper HTTP status codes
- Responsive Design for all screen sizes
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Developed with β€οΈ by Clariana Abreu
If you have any questions or need help with the project, feel free to:
- Open an issue on GitHub
- Contact the developer via GitHub profile
- Check the live demo at https://register-authentication-2.onrender.com
π This README.md provides comprehensive documentation for the authentication system, including setup instructions, deployment guide, and feature overview!