# Self hosted Elastic App Search add user via invitation not working

**URL:** <https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [January 10, 2020, 1:30pm UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601 "2020-01-10T13:30:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek.haith](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@abhishek.haith](https://discuss.elastic.co/u/abhishek.haith)\
**Post date:** [January 10, 2020, 1:30pm UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/1 "2020-01-10T13:30:01Z")

</div>

I have set up Elastic App Search in standard security mode.

Configuration picked from below document -

> **[App Search, Self Managed, Security and User Management | Swiftype Documentation](https://swiftype.com/documentation/app-search/self-managed/security#standard)**
>
> Learn how to get the most out of Swiftype

Also configured mailer so I am able to get invitation mail.

After submitting the create account form getting `Authentication has failed` error.

 ![Elastic App Search user registration failed](https://us1.discourse-cdn.com/elastic/original/3X/d/2/d22dc437ddfc9c0f6cb8d1d905b5ed5e59f4eced.png)

Logs on console -

```auto
appsearch_1 | [2020-01-10T12:49:24.958+00:00][13][2284][app-server][INFO]: [81d2d6bf-cd7e-4d29-956b-55c9783dd068] Started POST "/authenticate/accept_invitation" for 172.23.0.1 at 2020-01-10 12:49:24 +0000
appsearch_1 | [2020-01-10T12:49:24.990+00:00][13][2284][action_controller][INFO]: [81d2d6bf-cd7e-4d29-956b-55c9783dd068] Processing by AuthenticateController#accept_invitation as */*
appsearch_1 | [2020-01-10T12:49:24.995+00:00][13][2284][action_controller][INFO]: [81d2d6bf-cd7e-4d29-956b-55c9783dd068] Parameters: {"auth_strategy"=>"elasticsearch_standard", "user"=>{"password"=>"[FILTERED]"}, "lm_invitation_code"=>"hCYBOH9KuGvbgVQmOgUaQA", "host"=>"localhost:3002", "protocol"=>"http"}
appsearch_1 | [2020-01-10T12:49:25.063+00:00][13][2284][action_view][INFO]: [81d2d6bf-cd7e-4d29-956b-55c9783dd068] Rendered text template (0.2ms)
appsearch_1 | [2020-01-10T12:49:25.066+00:00][13][2284][action_controller][INFO]: [81d2d6bf-cd7e-4d29-956b-55c9783dd068] Completed 403 Forbidden in 69ms (Views: 10.3ms)

```

Please guide to make this working.

Thank you.

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [January 10, 2020, 4:50pm UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/2 "2020-01-10T16:50:57Z")

</div>

Hi @abhishek.haith 👋

From what I can tell this should only happen if the underlying Elasticsearch user has been deleted. What happens is that when App Search creates the invite it also creates the underlying Elasticsearch user.  
Can you verify if that user still exists as an Elasticsearch user with the [Get Users API](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html)?

---

<div class="post-metadata">

**Author:** ![abhishek.haith](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@abhishek.haith](https://discuss.elastic.co/u/abhishek.haith)\
**Post date:** [January 13, 2020, 12:27pm UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/3 "2020-01-13T12:27:59Z")

</div>

Hello @orhantoy

Thanks for giving idea how App Search manages users.

I checked the particular user in Elasticsearch with [Get User API](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html)

Found what is the actual issue.

I created the user with below information

Email: [john.doe@example.com](mailto:john.doe@example.com)  
Username: John Doe  
Role: Admin

App Search created user in Elasticsearch like below

```auto
{
    "John+Doe":
    {
        "username": "John+Doe",
        "roles": [],
        "full_name": "John Doe",
        "email": "john.doe@example.com",
        "metadata":
        {
            "created_by_app_search": true
        },
        "enabled": false
    }
}

```

I think user lookup getting failed when username has space in it.

Can we put validation on _Username_ field in invitation form?  
Or add this info in the documentation to avoid space in _Username_ field?

Thank you.

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [January 13, 2020, 2:11pm UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/4 "2020-01-13T14:11:33Z")

</div>

Awesome and very helpful debugging! 👏  
We'll try to get that sorted out for the next release.

---

<div class="post-metadata">

**Author:** ![abhishek.haith](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@abhishek.haith](https://discuss.elastic.co/u/abhishek.haith)\
**Post date:** [January 16, 2020, 11:05am UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/5 "2020-01-16T11:05:37Z")

</div>

Great 👏

Thank you 😃

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [January 21, 2020, 8:34pm UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/6 "2020-01-21T20:34:15Z")

</div>

@abhishek.haith This should now be fixed in today's [7.5.2 release](https://swiftype.com/documentation/app-search/self-managed/changelog#7-5-2).

---

<div class="post-metadata">

**Author:** ![abhishek.haith](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@abhishek.haith](https://discuss.elastic.co/u/abhishek.haith)\
**Post date:** [January 22, 2020, 7:18am UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/7 "2020-01-22T07:18:02Z")

</div>

Hi @orhantoy

I have tried to create a user with space in _Username_ on App Search Docker v7.5.2 and it worked! 😃 👏

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 19, 2020, 7:18am UTC](https://discuss.elastic.co/t/self-hosted-elastic-app-search-add-user-via-invitation-not-working/214601/8 "2020-02-19T07:18:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
