Login endpoint now return UserDRO

This commit is contained in:
Universall 2025-02-20 15:40:41 +03:00
parent 6aa09857f8
commit 40d7aacda2
3 changed files with 16 additions and 3 deletions

View File

@ -13,7 +13,6 @@ public class UserDTO {
private String name;
private String photo;
private String position;
private LocalDateTime lastVisit;
private Set<RoleModel> roles;
private boolean isActive;
private boolean isACSBlocked;

View File

@ -2,6 +2,7 @@ package com.displaynone.acss.controllers.auth;
import com.displaynone.acss.components.auth.AuthComponent;
import com.displaynone.acss.components.auth.models.AuthTokenPair;
import com.displaynone.acss.components.auth.models.user.UserMapper;
import com.displaynone.acss.components.auth.models.user.UserModel;
import com.displaynone.acss.exception.generics.BadRequestHTTPException;
import com.displaynone.acss.exception.generics.NotFoundHTTPException;
@ -21,7 +22,7 @@ public class AuthController {
private final AuthComponent authComponent;
@PostMapping("/login")
public ResponseEntity<AuthTokenPair> login(@RequestBody LoginRQB body) {
public ResponseEntity<LoginRSB> login(@RequestBody LoginRQB body) {
String login = body.getLogin();
String password = body.getPassword();
@ -35,7 +36,7 @@ public class AuthController {
throw new UnauthorizedHTTPException(e.getMessage());
}
return ResponseEntity.ok(authInfo.getSecond());
return ResponseEntity.ok(new LoginRSB(UserMapper.convertToDTO(authInfo.getFirst()), authInfo.getSecond()));
}
@PostMapping("/refresh")

View File

@ -0,0 +1,13 @@
package com.displaynone.acss.controllers.auth;
import com.displaynone.acss.components.auth.models.AuthTokenPair;
import com.displaynone.acss.components.auth.models.user.UserDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LoginRSB {
private UserDTO user;
private AuthTokenPair tokens;
}