Skip to content

User previously invited are DELETED when registering #5699

@microstudi

Description

@microstudi

Describe the bug

Users created through invitations are deleted when the same user register to Decidim independently. This causes tables having relations to that users to be orphan and potentially breaks the system.
One case where this happen is when a user is invited to a private space, if the user registers to the platform ignoring the invitation, the users created previously is deleted and a new one created. This leaves the ParticipatorySpacePrivateUser table orphan of the original link.

This is caused by the command CreateRegistration in this piece of code:

imatge

To Reproduce
Steps to reproduce the behavior:

  1. Go to a private space (ie, participatory process made private)
  2. Click on "private participants"
  3. Invite some user that is not in the platform yet.
  4. In a new private browser windoe, Register into the platform with the same user
  5. Return to the previous admin "private participants" page.
  6. Boom!

Note:
There's a mitigation in this #5698 but it does not tackle the problem itself, just ignores theses cases.

Expected behavior
Users registering into the platform should update already invited ones instead of deleting them.

Screenshots
N/A
Stacktrace

Started POST "/users?locale=es" for 127.0.0.1 at 2020-02-11 15:01:09 +0100
  Decidim::Organization Load (0.6ms)  SELECT  "decidim_organizations".* FROM "decidim_organizations" WHERE "decidim_organizations"."host" = $1 LIMIT $2  [["host", "localhost"], ["LIMIT", 1]]
  ↳ /home/ivan/projects/Decidim/decidim/decidim-core/app/middleware/decidim/current_organization.rb:36
Processing by Decidim::Devise::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"qBB62FcsI6jd+6Od9XZh2MhBCxdQ3RwZhiQJ2CSleKlyl8mbOPty3Yox5BR1lh3BQ6Rml9PG2sYMBtYE0oJx9Q==", "edmwpsjqiulryhfvo"=>"", "user"=>{"name"=>"Test", "nickname"=>"test", "email"=>"test@example.org", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "tos_agreement"=>"1", "newsletter"=>"1"}, "commit"=>"", "locale"=>"es"}
  Decidim::User Load (1.1ms)  SELECT  "decidim_users".* FROM "decidim_users" WHERE "decidim_users"."type" IN ('Decidim::User') AND "decidim_users"."invitation_token" IS NULL AND "decidim_users"."email" = $1 AND "decidim_users"."decidim_organization_id" = $2 LIMIT $3  [["email", "test@example.org"], ["decidim_organization_id", 1], ["LIMIT", 1]]
  ↳ /home/ivan/projects/Decidim/decidim/decidim-core/app/forms/decidim/registration_form.rb:36
  Decidim::User Load (1.0ms)  SELECT  "decidim_users".* FROM "decidim_users" WHERE "decidim_users"."type" IN ('Decidim::User') AND "decidim_users"."invitation_token" IS NULL AND "decidim_users"."nickname" = $1 AND "decidim_users"."decidim_organization_id" = $2 LIMIT $3  [["nickname", "test"], ["decidim_organization_id", 1], ["LIMIT", 1]]
  ↳ /home/ivan/projects/Decidim/decidim/decidim-core/app/forms/decidim/registration_form.rb:40
  Decidim::User Destroy (4.9ms)  DELETE FROM "decidim_users" WHERE "decidim_users"."type" IN ('Decidim::User') AND "decidim_users"."invitation_token" IS NOT NULL AND "decidim_users"."invitation_accepted_at" IS NULL AND "decidim_users"."email" = $1  [["email", "test@example.org"]]

Extra data (please complete the following information):

  • Device: any
  • Device OS: any
  • Browser: any
  • Decidim Version: all
  • Decidim installation: any

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions