This API provides endpoints for user registration, login, password reset, change password, and retrieving logged-in user details.
This API provides endpoints for user registration, login, password reset, change password, and retrieving logged-in user details.
- Clone the repository to your local machine.
- Install backend dependencies by navigating to the backend directory and running
npm install
. - Run the backend server using
npm run dev
. The server will start on port 8000. - Open the frontend directory in your code editor.
- Ensure that your frontend application (index.html) is set to run on port 5500 using live server.
A Postman collection is included in the backend folder for testing the API endpoints.
- Open Postman and import the provided collection (
ExpressAuthJWTAPI.postman_collection.json
). - Use the collection to test each API endpoint with different scenarios.
- Route:
POST /api/register
- Description: Register a new user with provided details.
- Request Body:
first_name
: User's first name.last_name
: User's last name.email
: User's email address.password
: User's password.
- Response:
message
: Success or error message.
- Route:
POST /api/login
- Description: Authenticate user and generate JWT token.
- Request Body:
email
: User's email address.password
: User's password.
- Response:
access_token
: JWT token for authenticated user.message
: Success or error message.
- Route:
POST /api/send-reset-password-email
- Description: Send email to user with password reset link.
- Request Body:
email
: User's email address.
- Response:
status
: Success or failure.message
: Success or error message.
- Route:
POST /api/reset-password/:id/:token
- Description: Reset user's password using reset token.
- Request Parameters:
id
: User's ID.token
: Reset token received in email.
- Request Body:
password
: New password.password_confirmation
: Confirm new password.
- Response:
status
: Success or failure.message
: Success or error message.
- Route:
POST /api/changepassword
- Description: Change user's password after authentication.
- Request Body:
new_password
: New password.confirm_password
: Confirm new password.
- Response:
status
: Success or failure.message
: Success or error message.
- Route:
GET /api/loggeduser
- Description: Retrieve details of logged-in user.
- Request Headers:
Authorization
: Bearer token.
- Response:
- User details (first name, last name, email, etc.).
If stuck somewhere, Fell free to reach at am6840957@gmail.com