|
| 1 | +package prod.oldboy.controllers; |
| 2 | + |
| 3 | +import io.swagger.v3.oas.annotations.Operation; |
| 4 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 5 | +import lombok.RequiredArgsConstructor; |
| 6 | +import lombok.extern.slf4j.Slf4j; |
| 7 | +import org.springframework.validation.annotation.Validated; |
| 8 | +import org.springframework.web.bind.annotation.PostMapping; |
| 9 | +import org.springframework.web.bind.annotation.RequestBody; |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | +import org.springframework.web.bind.annotation.RestController; |
| 12 | +import prod.oldboy.dto.jwt_dto.JwtAuthRequest; |
| 13 | +import prod.oldboy.dto.jwt_dto.JwtAuthResponse; |
| 14 | +import prod.oldboy.service.AuthService; |
| 15 | +import prod.oldboy.validation.group.LogInAction; |
| 16 | + |
| 17 | +@Slf4j |
| 18 | +@RestController |
| 19 | +@RequestMapping("/api/v1/auth") |
| 20 | +@RequiredArgsConstructor |
| 21 | +@Tag(name = "Authentication", description = "Method for authenticates account (enter login and password)") |
| 22 | +public class AuthController { |
| 23 | + |
| 24 | + private final AuthService authService; |
| 25 | + |
| 26 | + @PostMapping("/login") |
| 27 | + @Operation(summary = "Log in to the system", |
| 28 | + description = "Log in to the system and receive AccessToken") |
| 29 | + public JwtAuthResponse login(@Validated(LogInAction.class) |
| 30 | + @RequestBody JwtAuthRequest loginRequest) { |
| 31 | + |
| 32 | + log.info("AuthController: login method is start"); |
| 33 | + |
| 34 | + JwtAuthResponse response = authService.login(loginRequest); |
| 35 | + |
| 36 | + log.info("AuthController: login method is finished:" + response); |
| 37 | + |
| 38 | + return response; |
| 39 | + } |
| 40 | +} |
| 41 | + |
0 commit comments