Implementation of login endpoint.

This commit is contained in:
Florian THIERRY
2023-11-30 10:47:59 +01:00
parent 914785a29b
commit 36a7aacec7
13 changed files with 134 additions and 8 deletions

View File

@@ -0,0 +1,17 @@
package org.sportshub.exposition.configuration;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import org.sportshub.domain.exception.LoginFailureException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
@ControllerAdvice
public class GlobalControllerExceptionHandler {
@ResponseStatus(BAD_REQUEST)
@ExceptionHandler(LoginFailureException.class)
public void handleLoginFailureException() {
// Do nothing.
}
}

View File

@@ -1,11 +1,15 @@
package org.sportshub.exposition.user;
import java.util.List;
import java.util.Optional;
import org.sportshub.application.user.UserUseCases;
import org.sportshub.domain.user.model.User;
import org.sportshub.exposition.user.model.LoginRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -19,8 +23,8 @@ public class UserController {
}
@PostMapping("/login")
public String login() {
return "";
public String login(@RequestBody LoginRequest request) {
return userUseCases.authenticate(request.id(), request.password());
}
@GetMapping

View File

@@ -0,0 +1,8 @@
package org.sportshub.exposition.user.model;
import java.util.UUID;
public record LoginRequest(
UUID id,
String password
) {}