Merge pull request #16424 from CartoDB/bug/sc-232062/check-shared-entities-when-users-delete-themselves

[sc230232] Avoid deleting a user if it has shared entities
pull/16441/head
Shylpx 2 years ago committed by GitHub
commit 1f25b5f047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,6 +37,7 @@ Development
- Update browser version checker to allow Firefox/100.0 [#16415](https://github.com/CartoDB/cartodb/pull/16415)
- Update analysis schemas after giving required permissions on user promotion [#16390](https://github.com/CartoDB/cartodb/pull/16390)
- Add timeout for SQL API exports [#16377](https://github.com/CartoDB/cartodb/pull/16377)
- Avoid deleting a user if it has shared entities [#16424](https://github.com/CartoDB/cartodb/pull/16424)
- Remove all references to Spatial Data Catalog and Kepler GL maps in on-premises [#16293](https://github.com/CartoDB/cartodb/pull/16293)
- Increase hard-limit of MAX_TABLES_PER_IMPORT [#16374](https://github.com/CartoDB/cartodb/pull/16374)
- Guard code for vizjson users [#16267](https://github.com/CartoDB/cartodb/pull/16267)

@ -121,8 +121,8 @@ module Carto
force_destroy = params[:force].present?
if !force_destroy && @user.has_shared_entities?
error_message = "Can't delete @user. 'Has shared entities"
render_jsonp(error_message, 410 ) and return
error_message = "Can't delete user. Has shared entities"
render_jsonp(error_message, 401) and return
end
@user.set_force_destroy if force_destroy

@ -111,7 +111,13 @@ module Carto
deletion_password_confirmation = params[:deletion_password_confirmation]
if user.needs_password_confirmation? && !user.validate_old_password(deletion_password_confirmation)
render_jsonp({ message: "Error deleting user: #{PASSWORD_DOES_NOT_MATCH_MESSAGE}" }, 400) and return
render_jsonp({ message: "Error deleting user: #{PASSWORD_DOES_NOT_MATCH_MESSAGE}" }, 400)
return
end
if user.has_shared_entities?
render_jsonp({ message: "User can't be deleted because there are shared entities. Please, unshare or delete them and try again." }, 401)
return
end
user.destroy_account

Loading…
Cancel
Save