From b453289d7c46d01c81ce0da2f1bfa40a62591c1e Mon Sep 17 00:00:00 2001 From: sarojsingh2021 <saroj.kumarsingh@tarento.com> Date: Wed, 4 Jan 2023 15:31:55 +0530 Subject: [PATCH] fix-user-delete --- .../com/tarento/retail/controller/UserController.java | 8 ++------ src/main/java/com/tarento/retail/util/Sql.java | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/tarento/retail/controller/UserController.java b/src/main/java/com/tarento/retail/controller/UserController.java index a13298b..0517209 100644 --- a/src/main/java/com/tarento/retail/controller/UserController.java +++ b/src/main/java/com/tarento/retail/controller/UserController.java @@ -502,13 +502,9 @@ public class UserController { if (result.hasErrors()) { return ResponseGenerator.failureResponse(HttpStatus.UNPROCESSABLE_ENTITY.toString()); } - Boolean userTokenAvailable = userService.findUserByToken(authToken); - String username = ""; - if (userTokenAvailable) { - username = jwtTokenUtil.getUsernameFromToken(authToken); - User user = userService.findOne(username); - return ResponseGenerator.successResponse(userService.softDeleteUser(userDto)); + if (userService.softDeleteUser(userDto)) { + return ResponseGenerator.successResponse(true); } return ResponseGenerator.failureResponse("Invalid Token"); } diff --git a/src/main/java/com/tarento/retail/util/Sql.java b/src/main/java/com/tarento/retail/util/Sql.java index 75edd8e..f18c7f5 100644 --- a/src/main/java/com/tarento/retail/util/Sql.java +++ b/src/main/java/com/tarento/retail/util/Sql.java @@ -158,7 +158,7 @@ public interface Sql { final String FETCH_AUTH_TOKEN_REF = "SELECT id FROM user_authentication WHERE auth_token = ? "; final String REMOVE_USER_DEVICE_TOKEN = "DELETE from user_device WHERE user_auth_id IN (SELECT id FROM user_authentication WHERE auth_token =?) "; final String DELETE_USER = "DELETE from user WHERE id=?"; - final String SOFT_DELETE_USER = "UPDATE user SET deleted=1 WHERE id= ?"; + final String SOFT_DELETE_USER = "UPDATE user SET is_deleted=1, is_active = 0 WHERE id= ?"; final String DELETE_USER_ROLE = "DELETE from user_role where user_id=?"; final String DELETE_COUNTRY_USER = "DELETE from country_user where user_id=?"; -- GitLab