# Checking User Existence Rake

**URL:** https://meta.discourse.org/t/checking-user-existence-rake/311065
**Category:** Development
**Created:** [June 7, 2024, 12:07am UTC](https://meta.discourse.org/t/checking-user-existence-rake/311065 "2024-06-07T00:07:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![codethulu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codethulu/32/419120_2.png) [@codethulu](https://meta.discourse.org/u/codethulu)
#### Post date: [June 7, 2024, 12:07am UTC](https://meta.discourse.org/t/checking-user-existence-rake/311065/1 "2024-06-07T00:07:26Z")

</div>

Hello all, I am currently working on the [discourse-k8s-operator](https://github.com/canonical/discourse-k8s-operator), where I have developed an action that requires checking if the user _exists_. There does not seem to be an existing rake task for this, however (we also noticed a few rake tasks we would expect could exist did not also..)

For our purposes, we have patched discourse, but this feels like a small change that could fit in upstream! I have submitted a [PR](https://github.com/discourse/discourse/pull/27163), look forward to hearing your input!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [June 7, 2024, 12:33am UTC](https://meta.discourse.org/t/checking-user-existence-rake/311065/2 "2024-06-07T00:33:22Z")

</div>

If I understand your intent from looking at the github repo, Why not just use DISCOURSE\_DEVELOPER\_EMAIL and then when a user is created with that email address they are automatically an admin.

---

<div class="post-metadata">

### Author: ![codethulu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codethulu/32/419120_2.png) [@codethulu](https://meta.discourse.org/u/codethulu)
#### Post date: [June 10, 2024, 10:51am UTC](https://meta.discourse.org/t/checking-user-existence-rake/311065/3 "2024-06-10T10:51:00Z")

</div>

I’m not quite sure I understand, sorry.

We want to create some actions that a user could utilise when deploying discourse with the charm. One of these is to create a user account.

Since this behaviour is covered by a rake task, behaviour is isolated from the operator code, which can only execute the rake task, and [input through `stdin`](https://github.com/canonical/discourse-k8s-operator/blob/main/src/charm.py#L714).

If a user already exists, the rake task will ask some additional prompts, [asking if the password should be overwritten](https://github.com/discourse/discourse/blob/main/lib/tasks/admin.rake#L52). This means that the `stdin` will no longer be sufficient.

We have patched the `users:exists` rake task that has now been submitted as a PR to address this: we can check if the user exists already, and then adjust the `stdin` as appropriate.
