# Invite deleted user again

**URL:** https://meta.discourse.org/t/invite-deleted-user-again/188105
**Category:** Bug
**Created:** [April 26, 2021, 5:30am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105 "2021-04-26T05:30:55Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![hcw-rohan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hcw-rohan/32/218206_2.png) [@hcw-rohan](https://meta.discourse.org/u/hcw-rohan)
#### Post date: [April 26, 2021, 5:30am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/1 "2021-04-26T05:30:56Z")

</div>

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](https://meta.discourse.org/t/32566?silent=true), 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?

---

<div class="post-metadata">

### Author: ![weallwegot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/weallwegot/32/124753_2.png) [@weallwegot](https://meta.discourse.org/u/weallwegot)
#### Post date: [April 26, 2021, 10:51pm UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/2 "2021-04-26T22:51:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hcw-rohan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hcw-rohan/32/218206_2.png) [@hcw-rohan](https://meta.discourse.org/u/hcw-rohan)
#### Post date: [April 26, 2021, 11:03pm UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/3 "2021-04-26T23:03:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![weallwegot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/weallwegot/32/124753_2.png) [@weallwegot](https://meta.discourse.org/u/weallwegot)
#### Post date: [April 26, 2021, 11:23pm UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/4 "2021-04-26T23:23:56Z")

</div>

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:

```plaintext
{
    "invites": [],
    "can_see_invite_details": true,
    "counts": {
        "pending": 0,
        "expired": 0,
        "redeemed": 0,
        "total": 0
    }
}

```

> [@hcw-rohan](#):
>
> Is it possible to invite a user with an email address that has been previously deleted?

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

---

<div class="post-metadata">

### Author: ![hcw-rohan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hcw-rohan/32/218206_2.png) [@hcw-rohan](https://meta.discourse.org/u/hcw-rohan)
#### Post date: [April 26, 2021, 11:42pm UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/5 "2021-04-26T23:42:59Z")

</div>

Ah sorry, should have specified the endpoint. [Discourse API Docs](https://docs.discourse.org/#tag/Invites/paths/~1invites.json/post)

The steps I took were:

- Invite user using the POST endpoint [Discourse API Docs](https://docs.discourse.org/#tag/Invites/paths/~1invites.json/post)
- 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”  
}

```plaintext

```

---

<div class="post-metadata">

### Author: ![hcw-rohan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hcw-rohan/32/218206_2.png) [@hcw-rohan](https://meta.discourse.org/u/hcw-rohan)
#### Post date: [April 26, 2021, 11:49pm UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/6 "2021-04-26T23:49:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![weallwegot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/weallwegot/32/124753_2.png) [@weallwegot](https://meta.discourse.org/u/weallwegot)
#### Post date: [April 27, 2021, 12:06am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/7 "2021-04-27T00:06:16Z")

</div>

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**

```plaintext
{
    "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](mailto: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**

```plaintext
{
    "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**

```plaintext
{
    "failed": "FAILED"
}

```

---

<div class="post-metadata">

### Author: ![hcw-rohan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hcw-rohan/32/218206_2.png) [@hcw-rohan](https://meta.discourse.org/u/hcw-rohan)
#### Post date: [April 27, 2021, 1:04am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/8 "2021-04-27T01:04:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![weallwegot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/weallwegot/32/124753_2.png) [@weallwegot](https://meta.discourse.org/u/weallwegot)
#### Post date: [April 27, 2021, 1:10am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/9 "2021-04-27T01:10:06Z")

</div>

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](https://meta.discourse.org/t/how-to-write-a-good-bug-report/183671)

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

---

<div class="post-metadata">

### Author: ![harirajv](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@harirajv](https://meta.discourse.org/u/harirajv)
#### Post date: [May 3, 2021, 4:57pm UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/10 "2021-05-03T16:57:48Z")

</div>

@hcw-rohan @weallwegot This bug has been fixed in [#12927](https://github.com/discourse/discourse/pull/12927).

---

<div class="post-metadata">

### Author: ![gregthepeg4](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@gregthepeg4](https://meta.discourse.org/u/gregthepeg4)
#### Post date: [June 23, 2021, 8:58am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/12 "2021-06-23T08:58:55Z")

</div>

Hi,

I think that perhaps the bug fix has been reverted or no longer works as I encountered this bug today. I followed the steps below to identify the problem.

- Deleted a user in the admin panel
- Invited the user via the API
- Got the failed message

  

- Deleted the pending invites for the deleted user

- Invited the deleted user via the API

- Got the success message

- Received the invite but when clicked I got the warning “Sorry! This invitation is intended for new users, who do not already have an existing account.”

- Neither the API or the admin panel can find the deleted user  
\*Finally, I tried to open the invite link in an incognito window and I was then able to log in as a new user- possible a problem with cookies?  
  

- Tried to add a new user via the API

- Get the success message  
  

Hope this helps.

---

<div class="post-metadata">

### Author: ![dan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dan/32/101549_2.png) [@dan](https://meta.discourse.org/u/dan)
#### Post date: [July 6, 2021, 8:33am UTC](https://meta.discourse.org/t/invite-deleted-user-again/188105/14 "2021-07-06T08:33:56Z")

</div>

Hello Greg,

I tried to reproduce the bug, but for me it worked to re-invite a user who was deleted. I tried using both email and link invites.

> [@gregthepeg4](#):
>
> - Received the invite but when clicked I got the warning “Sorry! This invitation is intended for new users, who do not already have an existing account.”

Are you sure that you were not logged in when you accessed the invite page? There is a single code path that displays this message and I see no obvious problems.
