Checking User Existence Rake

Hello all, I am currently working on the 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, look forward to hearing your input!

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.

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.

If a user already exists, the rake task will ask some additional prompts, asking if the password should be overwritten. 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.

1 Like