This repository contains the backend for the Don's Pay project, developed using Java Spring Boot. The backend handles user authentication and registration and integrates with a MySQL database.
- User registration and login functionality.
- Password encryption using BCrypt.
- Integration with MySQL database.
- Secure authentication with Spring Security.
- Java 17 or higher.
- MySQL database server.
- Maven (for dependency management).
git clone https://github.com/Vijayagiridharan/Don-s-Pay.git
cd dons-pay-backendCreate a MySQL database named user_transactions_db. Use the following credentials:
- URL:
jdbc:mysql://localhost:3306/user_transactions_db - Username:
Donspay - Password:
donspay@123
Alternatively, update the database configuration in src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/user_transactions_db
spring.datasource.username=Donspay
spring.datasource.password=donspay@123
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=trueUse Maven to build and run the application:
mvn clean install
mvn spring-boot:run- URL:
POST /api/auth/login - Request Body:
{ "email": "[email protected]", "password": "securepassword" } - Response:
- Success:
200 OK{ "message": "Login successful for user: [email protected]" } - Failure:
401 Unauthorizedor other relevant error messages.
- Success:
- URL:
POST /api/auth/register - Request Body:
{ "email": "[email protected]", "password": "securepassword" } - Response:
- Success:
201 Created{ "message": "User registered successfully" }
- Success:
Use a MySQL client or GUI to verify that users are stored in the users table with encrypted passwords.
src/main/java/com/acs560/dons_pay_backendentity/User.java- User entity class mapped to the database.repository/UserRepository.java- Interface for database operations.service/AuthService.java- Handles authentication logic.controller/AuthController.java- REST controller for authentication endpoints.DonsPayBackendApplication.java- Main Spring Boot application file.
-
Database Connection Issues:
- Ensure MySQL is running and accessible.
- Verify database credentials in
application.properties.
-
Invalid Credentials:
- Ensure the password is correctly hashed during registration.
- Use
BCryptPasswordEncoderto verify passwords.
-
Spring Security Configuration:
- Verify the
/api/auth/loginendpoint is allowed without prior authentication.
- Verify the
- Add user roles and permissions.
- Integrate JWT for session management.
- Implement additional endpoints for transaction management.
This project is licensed under the MIT License.
For further assistance, contact Anshul Abrol.