Invite deleted user again

Probably an edge case here but while testing an API endpoint (/invites.json) all works well. I then deleted the invited user and now I get a 422 response from that endpoint. Using the data explorer, I can see the user no longer exists, but the invite is still listed in the invites table.

Is it possible to invite a user with an email address that has been previously deleted?

4 Likes

Hi, welcome! To clarify - had the invited user accepted the invite/made their account prior to you deleting them?

1 Like

Thanks! Yes I accepted the invite, then deleted the account

1 Like

Okay I haven’t been able to reproduce the way you’ve described unless i’m misunderstanding something about what you are hoping to do (totally possible). It might help if you explain what you expected to see vs what you are actually seeing.

But I’m using:

Version: 2.7.0beta7
OS: Ubuntu 20.04.1 LTS

& i did the following:

  • invite user with a specific email address from the UI, Admin > Users > Send Invites
    • Invite and selected the option to restrict invite to a specific email address
  • accepted the invite from the specified email address in a separate incognito window
  • as an admin user in my original window - deleted the newly signed up user
  • used Postman to send a GET to https://example.dev/u/my-dev-user/invited.json
    • is this the endpoint you were using? you mentioned /invites.json but i get a 404 using that regardless, i’m not entirely sure it exists.
  • Received the following response after deleting the user, which is what i expected since I deleted the user none pending, none redeemed, and none expired:
{
    "invites": [],
    "can_see_invite_details": true,
    "counts": {
        "pending": 0,
        "expired": 0,
        "redeemed": 0,
        "total": 0
    }
}

should be able to - i just re-invited that same email i deleted above without any issue.

2 Likes

Ah sorry, should have specified the endpoint. Discourse API Docs

The steps I took were:

  • Invite user using the POST endpoint Discourse API Docs
  • Accept the invite via email
  • Login as admin and delete the user
  • Attempt to invite the user via step 1 again. This time I get a 422 response with error: ```
    {
    “failed”: “FAILED”
    }
2 Likes

Ah and just to follow up, the invite works via the admin interface as you described, but not via the POST endpoint that I’m using.

1 Like

Oooh got it this is clear now - yea, this I’m able to reproduce now.

I’m able to send regular invites to brand new emails from the API with a post request:
I get the following response as expected:

REQUEST: https://example.dev/invites.json?email=example%2Bsomething@hey.com
ACTUAL RESPONSE

{
    "id": 7,
    "invite_key": "inviteKEY",
    "link": "https://example.dev/invites/inviteKEY",
    "email": "example+something@hey.com",
    "emailed": true,
    "custom_message": null,
    "created_at": "2021-04-26T23:57:08.602Z",
    "updated_at": "2021-04-26T23:57:08.602Z",
    "expires_at": "2021-05-26T23:57:08.594Z",
    "expired": false,
    "topics": [],
    "groups": []
}
  • then I log in elsewhere and accept the invite for that user.
  • then i log back in as the admin & delete the user with email: example+something@hey.com
  • next I re-send the same POST request to the API to invite that user again

REQUEST: https://example.dev/invites.json?email=example%2Bsomething@hey.com
EXPECTED RESPONSE

{
    "id": 8,
    "invite_key": "newinviteKEY",
    "link": "https://example.dev/invites/newinviteKEY",
    "email": "example+something@hey.com",
    "emailed": true,
    "custom_message": null,
    "created_at": "2021-04-26T23:59:08.602Z",
    "updated_at": "2021-04-26T23:59:08.602Z",
    "expires_at": "2021-05-26T23:59:08.594Z",
    "expired": false,
    "topics": [],
    "groups": []
}

ACTUAL RESPONSE

{
    "failed": "FAILED"
}
3 Likes

Ah good it wasn’t just me :slight_smile: So I’m new to this, does this get reported as a bug now or is there somewhere else to post it eg github?

1 Like

this should serve as the report if i understand correctly! between the two of us i think we should have mostly hit the standard for a bug report

& then hopefully someone who can provide an explanation, workaround, and/or fix will let us know what to do.

6 Likes

@hcw-rohan @weallwegot This bug has been fixed in #12927.