This project is a user authentication system built using NestJS, MongoDB, Prisma, and Docker. It includes 2-Factor Authentication (2FA) with QR code support.
- Node.js and npm: Install Node.js and npm from https://nodejs.org/.
- Docker: Install Docker from https://www.docker.com/get-started.
- Docker Compose: Install Docker Compose from https://docs.docker.com/compose/install/.
-
Clone the repository:
git clone https://github.com/neecatt/UserAuthSystem.git
-
Install dependencies:
npm install
-
Set up environment variables:
Rename .env.example to .env. Update .env file with your MongoDB connection URI and JWT secret.
-
Build and run the application using Docker:
docker-compose up -d
-
Run the application:
npm run start:dev
-
Access the application:
- The application will be running at http://localhost:3000.
- The GraphQL Playground can be accessed at http://localhost:3000/graphql.
- Register a new user using the register mutation.
- Log in with your registered user using the login mutation.
- To enable 2FA, use the enableTwoFactorAuthentication mutation. This will return a QR code for configuring an authenticator app.
- Authenticate with 2FA using the authenticateTwoFactor mutation and the 6-digit code from your authenticator app.
- You can change your password using the changePassword mutation.