Skip to content

Commit

Permalink
add response type on LoginController
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudFonzam committed Jul 10, 2023
1 parent ca8697c commit 3bf1190
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/main/java/org/isf/login/dto/LoginResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@
*/
package org.isf.login.dto;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "Class representing a Login response")
public class LoginResponse {

@Schema(description = "token")
private String token;

@Schema(description = "type of Token", example = "Bearer")
private String type = "Bearer";

@Schema(description = "user name", example = "admin")
private String username;

public LoginResponse(String token, String username) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/isf/login/rest/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class LoginController {
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(LoginController.class);

@PostMapping(value = "/auth/login", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity< ? > authenticateUser(@Valid @RequestBody LoginRequest loginRequest) throws OHAPIException {
public ResponseEntity<LoginResponse> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) throws OHAPIException {
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));
SecurityContextHolder.getContext().setAuthentication(authentication);
Expand Down

0 comments on commit 3bf1190

Please sign in to comment.