пПолучение списка доступа.
This commit is contained in:
@ -500,26 +500,17 @@ public class MainController implements ServletContextAware {
|
|||||||
@RequestMapping(value = "/access", method = {RequestMethod.POST}, produces = "application/json;charset=utf-8")
|
@RequestMapping(value = "/access", method = {RequestMethod.POST}, produces = "application/json;charset=utf-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<Object> access(
|
public ResponseEntity<Object> access(
|
||||||
Model model,
|
Authentication authentication,
|
||||||
@CookieValue(value = "jwt_a", defaultValue = "") String jwt_a,
|
|
||||||
@Nullable @RequestBody ActionNameModel action_name,
|
@Nullable @RequestBody ActionNameModel action_name,
|
||||||
@CookieValue(value = "lng", defaultValue = "1") String language_id
|
@CookieValue(value = "lng", defaultValue = "1") String language_id
|
||||||
) {
|
) {
|
||||||
Translation trt = new Translation(language_id, jdbcTemplate);
|
Translation trt = new Translation(language_id, jdbcTemplate);
|
||||||
try {
|
try {
|
||||||
if (jwt_a.isEmpty() || countOccurrences(jwt_a, '.') != 2) {
|
if (authentication == null || !authentication.isAuthenticated()) {
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(10000, trt.trt(false, "Please_log_in"), null, null), HttpStatus.INTERNAL_SERVER_ERROR);
|
String uuid = UUID.randomUUID().toString();
|
||||||
}
|
return new ResponseEntity<>(new ErrorResponseModel(10401, trt.trt(false, "Please_log_in"), null, uuid), HttpStatus.UNAUTHORIZED);
|
||||||
|
|
||||||
Jws<Claims> claims;
|
|
||||||
try {
|
|
||||||
claims = Jwts.parserBuilder()
|
|
||||||
.setSigningKey(getPublicKey())
|
|
||||||
.build()
|
|
||||||
.parseClaimsJws(jwt_a);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(10000, Arrays.asList(trt.trt(false, "Please_log_in"), trt.trt(false, "JWT_token_verification_error")), null, null), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
}
|
||||||
|
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||||
|
|
||||||
String sql = """
|
String sql = """
|
||||||
select
|
select
|
||||||
@ -533,7 +524,7 @@ public class MainController implements ServletContextAware {
|
|||||||
""";
|
""";
|
||||||
|
|
||||||
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
||||||
parameters.addValue("user_id", claims.getBody().get("user_id"));
|
parameters.addValue("user_id", userDetails.getUserId());
|
||||||
if (action_name == null) {
|
if (action_name == null) {
|
||||||
parameters.addValue("action_name", null);
|
parameters.addValue("action_name", null);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user