This repository provides a starting point for building secure and robust authentication systems with Nuxt.js. It's designed to be a comprehensive template that includes all the necessary features for managing user accounts, from registration and login to password recovery and account verification via emails.
-
User Management:
- Registration
- Login
- Session Persistence (Refresh Tokens)
- Email Verification
- Account Update
- Account Deletion
- Password Reset
-
Robust Security:
- Password Hashing (bcrypt)
- JWT Authentication
- Email Verification for Account Confirmation
-
Scalable Architecture:
- Nuxt as the full-stack framework
- MongoDB as a non-relational database
- Prisma as the ORM for managing the database
- Nodemailer for sending emails
- Zod for data validation
- Handlebars for dynamic templates
- Clone the repository:
git clone https://github.com/vircoding/nuxt-authentication-starter-template.git
cd nuxt-authentication-starter-template
- Install dependencies:
npm install
- Setup environment variables:
- Create a .env file in the root directory based on the .env.example file provided.
- Fill in the following environment variables:
DATABASE_URL=<your-mongodb-url>
JWT_REFRESH_SECRET=<your-refresh-secret-key>
JWT_ACCESS_SECRET=<your-access-secret-key>
JWT_VERIFICATION_SECRET=<your-verification-secret-key>
EMAIL_HOST=<host-for-sending-emails>
EMAIL_USER=<your-email>
EMAIL_PASSWORD=<your-email-password>
- Run the development server:
npm run dev
- Access the server: The server will be available at http://localhost:3000.
The API uses JWTs for authentication. Access tokens are generated when a user logs in, and refresh tokens are used to obtain new access tokens when the access token expires.
Email verification is handled using Nodemailer. When a new user is created, a verification email is sent to their email address.
Zod is used to validate user data. This helps ensure that data is in the correct format and meets the required constraints.
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Feel free to open an issue or submit a pull request.
This template is intended to be a starting point to building a full-stack application. It is not intended to be a complete solution. You may need to modify the code and add additional features to meet your specific needs.