This project is a full-stack authentication service built using Angular for the front end and Node.js for the back end. It provides a secure authentication mechanism for users to log in, access protected resources, and perform CRUD activities on data. The authentication process involves token-based authentication using JSON Web Tokens (JWT) to ensure secure communication between the client and the server.
- User registration: Users can login as Admin and create their personal accounts by providing their information.
- User authentication: Created users can log in using their email and password credentials.
- Token-based authentication: The authentication process generates JWTs, which are used to authenticate and authorize users for subsequent requests.
- Password hashing: User passwords are securely hashed using bcrypt before storing them in the database.
- Protected routes: Certain routes are protected and require authentication to access.
- Frontend: Angular, Tailwind, PrimeNg
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: JSON Web Tokens (JWT)
- Password Hashing: bcrypt
Before running this project, make sure you have the following installed:
- Node.js and npm
- Angular CLI
- MongoDB, Mongoose
-
Clone this repository:
git clone https://github.com/emmanuelobi/auth-service.git
-
Navigate to the project directory:
cd auth-service
-
Install dependencies for both frontend and backend:
cd frontend npm install cd ../backend npm install ## Configuration
-
Backend Configuration:
- Create a
.env
file in the backend directory. - Configure environment variables including database connection string, JWT secret, etc.
- Create a
-
Frontend Configuration:
- Modify environment files (
environment.ts
andenvironment.prod.ts
) in thesrc/environments
directory to set appropriate API endpoint URLs.
- Modify environment files (
-
Start the Backend Server:
- Navigate to the backend directory:
cd backend
- Start the server:
npm start
- Navigate to the backend directory:
-
Start the Frontend Development Server:
- Navigate to the frontend directory:
cd frontend
- Run the Angular development server:
ng serve
- Navigate to the frontend directory:
-
Access the application in your web browser at
http://localhost:4200
.
- Login with Admin details, create a new user by providing your information.
- Log in using your created user information.
- Access protected resources or features available only to authenticated users.