buerokratt / Buerokratt-Chatbot

1 stars 16 forks source link

Administrator can remove existing user #114

Open janinakimtrohlev opened 1 year ago

janinakimtrohlev commented 1 year ago

AS AN Administrator of Bürokratt, I WANT TO be able to remove a single selected user from a table of all users SO THAT they cannot log in anymore.

Acceptance criteria

janinakimtrohlev commented 1 year ago

BUG - If I try to delete an existing user it gives notification " Do I want to delete user" and if I push Yes, then comes notification that user is deleted but user is still in list of users. Should be when I delete user it should be deleted and should disappear from list of users.

varmoh commented 1 year ago
2023-08-22T08:14:25.364Z INFO [f7df4a62baa1b88f,f7df4a62baa1b88f]  : Request body: {"userIdCode":"39003150230","created":"2023-08-22T08:14:25.363540Z"}
2023-08-22T08:14:27.472Z INFO [f7df4a62baa1b88f,f7df4a62baa1b88f]  : HTTP POST for uri http://resql:8082/delete-user response code 400 BAD_REQUEST
2023-08-22T08:14:27.472Z INFO [f7df4a62baa1b88f,f7df4a62baa1b88f]  : Response body: {"error":"DuplicateKeyException","message":"PreparedStatementCallback; SQL [WITH active_administrators AS (SELECT user_id\n                               FROM user_authority\n                               WHERE 'ROLE_ADMINISTRATOR' = ANY (authority_name)\n                                 AND id IN (SELECT max(id)\n                                            FROM user_authority\n                                            GROUP BY user_id))\nINSERT\nINTO customer_support_agent_activity (id_code, active, created, status)\nSELECT ?, 'false', ?::timestamp with time zone, 'offline'\nWHERE (1 < (SELECT COUNT(*) FROM active_administrators)\n    OR (1 = (SELECT COUNT(*) FROM active_administrators)\n        AND ? NOT IN (SELECT * FROM active_administrators)));\n\nWITH active_administrators AS (SELECT user_id\n                               FROM user_authority\n                               WHERE 'ROLE_ADMINISTRATOR' = ANY (authority_name)\n                                 AND id IN (SELECT max(id)\n                                            FROM user_authority\n                                            GROUP BY user_id))\nINSERT\nINTO \"user\" (login, password_hash, first_name, last_name, id_code, display_name, status, created, csa_title, csa_email)\nSELECT login,\n       password_hash,\n       first_name,\n       last_name,\n       id_code,\n       display_name,\n       'deleted',\n       ?::timestamp with time zone,\n       csa_title,\n       csa_email\nFROM \"user\"\nWHERE id_code = ?\n  AND status <> 'deleted'\n  AND id IN (SELECT max(id) FROM \"user\" WHERE id_code = ?)\n  AND (1 < (SELECT COUNT(*) FROM active_administrators)\n    OR (1 = (SELECT COUNT(*) FROM active_administrators)\n        AND ? NOT IN (SELECT * FROM active_administrators)));\n\nWITH active_administrators AS (SELECT user_id\n                               FROM user_authority\n                               WHERE 'ROLE_ADMINISTRATOR' = ANY (authority_name)\n                                 AND id IN (SELECT max(id)\n                                            FROM user_authority\n                                            GROUP BY user_id))\nINSERT\nINTO user_authority (user_id, authority_name, created)\nSELECT ?, ARRAY []::varchar[], ?::timestamp with time zone\nFROM user_authority\nWHERE 1 < (SELECT COUNT(*) FROM active_administrators)\n   OR (1 = (SELECT COUNT(*) FROM active_administrators)\n    AND ? NOT IN (SELECT * FROM active_administrators));\n\nWITH active_administrators AS (SELECT user_id\n                               FROM user_authority\n                               WHERE 'ROLE_ADMINISTRATOR' = ANY (authority_name)\n                                 AND id IN (SELECT max(id)\n                                            FROM user_authority\n                                            GROUP BY user_id))\nINSERT\nINTO user_profile_settings (user_id, forwarded_chat_popup_notifications, forwarded_chat_sound_notifications, forwarded_chat_email_notifications, new_chat_popup_notifications, new_chat_sound_notifications, new_chat_email_notifications, use_autocorrect)\nSELECT ?, false, false, false, false, false, false, false\nWHERE 1 < (SELECT COUNT(*) FROM active_administrators)\n   OR (1 = (SELECT COUNT(*) FROM active_administrators)\n    AND ? NOT IN (SELECT * FROM active_administrators));\n]; ERROR: duplicate key value violates unique constraint \"user_profile_settings_pkey\"\n  Detail: Key (user_id)=(39003150230) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint \"user_profile_settings_pkey\"\n  Detail: Key (user_id)=(39003150230) already exists."}
2023-08-22T08:14:27.473Z INFO [f7df4a62baa1b88f,f7df4a62baa1b88f]  : Error handling action was to stop the request all together.

Logs from when the action is being done

rasmusei commented 1 year ago

Tested and OK