Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sc230232] Avoid deleting a user if it has shared entities #16424

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/carto/api/organization_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def destroy
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
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/carto/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ def delete_me
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
Expand Down