diff --git a/helpapp-backend/manage-services.sh b/helpapp-backend/manage-services.sh new file mode 100755 index 0000000..0d0f4e6 --- /dev/null +++ b/helpapp-backend/manage-services.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# List of services +services=("user-service" "request-service" "volunteer-service" "feedback-service" "administration-service") + +# Function to start services +start_services() { + for service in "${services[@]}"; do + echo "Starting $service..." + mvn spring-boot:run -pl $service & + done +} + +# Function to stop services +stop_services() { + echo "Stopping all services..." + pkill -f 'mvn spring-boot:run' + for port in {8080..8085}; do + echo "Killing process on port $port..." + fuser -k $port/tcp + done +} + +# Check command line arguments +if [ "$1" == "start" ]; then + start_services +elif [ "$1" == "stop" ]; then + stop_services +else + echo "Usage: $0 {start|stop}" +fi \ No newline at end of file diff --git a/helpapp-backend/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java b/helpapp-backend/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java index e28966f..8169b18 100644 --- a/helpapp-backend/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java +++ b/helpapp-backend/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java @@ -2,8 +2,8 @@ package insa.application.helpapp.rest; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.*; import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -55,12 +55,12 @@ public class UserServiceApplication { // Authenticate a user @PostMapping("/authenticate") - public String authenticate(@RequestParam String email, @RequestParam String password) { + public AuthResponse authenticate(@RequestBody AuthRequest authRequest) { return userDatabase.values().stream() - .filter(user -> user.getEmail().equals(email) && user.getPassword().equals(password)) + .filter(user -> user.getEmail().equals(authRequest.getEmail()) && user.getPassword().equals(authRequest.getPassword())) .findFirst() - .map(user -> "Authentication successful for user ID: " + user.getId()) - .orElse("Authentication failed"); + .map(user -> new AuthResponse(user.getId(), "Authentication successful", true)) + .orElse(new AuthResponse(null, "Authentication failed", false)); } // Update user details (excluding password) @@ -90,6 +90,52 @@ public class UserServiceApplication { return "User deleted successfully"; } + // Data transfer objects + static class AuthRequest { + private String email; + private String password; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + } + + static class AuthResponse { + private Long userId; + private String message; + private boolean success; + + public AuthResponse(Long userId, String message, boolean success) { + this.userId = userId; + this.message = message; + this.success = success; + } + + public Long getUserId() { + return userId; + } + + public String getMessage() { + return message; + } + + public boolean isSuccess() { + return success; + } + } + // User entity static class User { private Long id; @@ -98,7 +144,6 @@ public class UserServiceApplication { private String password; private String role; // REQUESTER, VOLUNTEER, ADMIN - // Getters and setters public Long getId() { return id; } diff --git a/helpapp-frontend/index.html b/helpapp-frontend/index.html index 77e6dcb..693981f 100644 --- a/helpapp-frontend/index.html +++ b/helpapp-frontend/index.html @@ -4,61 +4,22 @@