Implementation of login endpoint.
This commit is contained in:
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.sportshub.exposition.user.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record LoginRequest(
|
||||
UUID id,
|
||||
String password
|
||||
) {}
|
||||
Reference in New Issue
Block a user