Spaces:
No application file
No application file
Cập nhật response sau login
Browse files- connexa-parent/connexa-admin/src/main/java/org/connexa/connexaadmin/auth/AuthController.java +4 -1
- connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/auth/AuthController.java +4 -3
- connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/RoleController.java +0 -22
- connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/RoleRepository.java +0 -9
- connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/RoleService.java +0 -9
- connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/impl/RoleServiceImpl.java +0 -20
connexa-parent/connexa-admin/src/main/java/org/connexa/connexaadmin/auth/AuthController.java
CHANGED
|
@@ -90,7 +90,10 @@ public class AuthController {
|
|
| 90 |
refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60); // 7 ngay
|
| 91 |
httpServletResponse.addCookie(refreshTokenCookie);
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
| 94 |
}catch (BadCredentialsException ex) {
|
| 95 |
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
| 96 |
}
|
|
|
|
| 90 |
refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60); // 7 ngay
|
| 91 |
httpServletResponse.addCookie(refreshTokenCookie);
|
| 92 |
|
| 93 |
+
Map<String, Object> result = new HashMap<>();
|
| 94 |
+
result.put("accessToken", token.getAccessToken());
|
| 95 |
+
|
| 96 |
+
return new ResponseEntity<>(result, HttpStatus.OK);
|
| 97 |
}catch (BadCredentialsException ex) {
|
| 98 |
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
| 99 |
}
|
connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/auth/AuthController.java
CHANGED
|
@@ -5,8 +5,6 @@ import jakarta.servlet.http.HttpServletRequest;
|
|
| 5 |
import jakarta.servlet.http.HttpServletResponse;
|
| 6 |
import jakarta.validation.Valid;
|
| 7 |
import org.connexa.connexaweb.account.AccountService;
|
| 8 |
-
import org.connexa.connexaweb.auth.RefreshTokenRequest;
|
| 9 |
-
import org.connexa.connexaweb.auth.TokenService;
|
| 10 |
import org.connexa.connexaweb.security.CustomUserDetails;
|
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 12 |
import org.springframework.http.HttpStatus;
|
|
@@ -92,7 +90,10 @@ public class AuthController {
|
|
| 92 |
refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60); // 7 ngay
|
| 93 |
httpServletResponse.addCookie(refreshTokenCookie);
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
}catch (BadCredentialsException ex) {
|
| 97 |
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
| 98 |
}
|
|
|
|
| 5 |
import jakarta.servlet.http.HttpServletResponse;
|
| 6 |
import jakarta.validation.Valid;
|
| 7 |
import org.connexa.connexaweb.account.AccountService;
|
|
|
|
|
|
|
| 8 |
import org.connexa.connexaweb.security.CustomUserDetails;
|
| 9 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 10 |
import org.springframework.http.HttpStatus;
|
|
|
|
| 90 |
refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60); // 7 ngay
|
| 91 |
httpServletResponse.addCookie(refreshTokenCookie);
|
| 92 |
|
| 93 |
+
Map<String, Object> result = new HashMap<>();
|
| 94 |
+
result.put("accessToken", token.getAccessToken());
|
| 95 |
+
|
| 96 |
+
return new ResponseEntity<>(result, HttpStatus.OK);
|
| 97 |
}catch (BadCredentialsException ex) {
|
| 98 |
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
| 99 |
}
|
connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/RoleController.java
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
package org.connexa.connexaweb.role;
|
| 2 |
-
|
| 3 |
-
import org.connexa.connexaweb.role.RoleService;
|
| 4 |
-
import org.springframework.http.HttpStatus;
|
| 5 |
-
import org.springframework.http.ResponseEntity;
|
| 6 |
-
import org.springframework.web.bind.annotation.GetMapping;
|
| 7 |
-
import org.springframework.web.bind.annotation.RequestMapping;
|
| 8 |
-
import org.springframework.web.bind.annotation.RestController;
|
| 9 |
-
|
| 10 |
-
@RestController
|
| 11 |
-
@RequestMapping("/api/roles")
|
| 12 |
-
public class RoleController {
|
| 13 |
-
private final RoleService roleService;
|
| 14 |
-
public RoleController(RoleService roleService){
|
| 15 |
-
this.roleService = roleService;
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
@GetMapping
|
| 19 |
-
public ResponseEntity<?> list(){
|
| 20 |
-
return new ResponseEntity<>(roleService.roles(), HttpStatus.OK);
|
| 21 |
-
}
|
| 22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/RoleRepository.java
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
package org.connexa.connexaweb.role;
|
| 2 |
-
|
| 3 |
-
import org.connexa.connexacommon.entity.Role;
|
| 4 |
-
import org.springframework.data.jpa.repository.JpaRepository;
|
| 5 |
-
import org.springframework.stereotype.Repository;
|
| 6 |
-
|
| 7 |
-
@Repository
|
| 8 |
-
public interface RoleRepository extends JpaRepository<Role, Integer> {
|
| 9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/RoleService.java
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
package org.connexa.connexaweb.role;
|
| 2 |
-
|
| 3 |
-
import org.connexa.connexacommon.entity.Role;
|
| 4 |
-
|
| 5 |
-
import java.util.List;
|
| 6 |
-
|
| 7 |
-
public interface RoleService {
|
| 8 |
-
public List<Role> roles();
|
| 9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connexa-parent/connexa-web/src/main/java/org/connexa/connexaweb/role/impl/RoleServiceImpl.java
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
package org.connexa.connexaweb.role.impl;
|
| 2 |
-
|
| 3 |
-
import org.connexa.connexaweb.role.RoleRepository;
|
| 4 |
-
import org.connexa.connexaweb.role.RoleService;
|
| 5 |
-
import org.connexa.connexacommon.entity.Role;
|
| 6 |
-
import org.springframework.stereotype.Service;
|
| 7 |
-
|
| 8 |
-
import java.util.List;
|
| 9 |
-
|
| 10 |
-
@Service
|
| 11 |
-
public class RoleServiceImpl implements RoleService {
|
| 12 |
-
private RoleRepository roleRepository;
|
| 13 |
-
public RoleServiceImpl(RoleRepository roleRepository){
|
| 14 |
-
this.roleRepository = roleRepository;
|
| 15 |
-
}
|
| 16 |
-
@Override
|
| 17 |
-
public List<Role> roles() {
|
| 18 |
-
return roleRepository.findAll();
|
| 19 |
-
}
|
| 20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|