dyne / reflow-os

Base scripts to run Reflow OS
7 stars 2 forks source link

Wish: graphql mutation for creating (and approving) users #4

Closed ocataco closed 2 years ago

ocataco commented 2 years ago

For the simulations I'm working on it would be great to script the making and approving of test users (with agents) instead of doing this by hand.

mayel commented 2 years ago

Hi @ocataco that's easy enough do to in Elixir, see for example the seeds script: https://github.com/dyne/bonfire-app/blob/main/flavours/reflow/repo/seeds.exs#L14

mayel commented 2 years ago

As you probably found, there isn't currently a graphql API for users (other than simply logging in), though that's of course somewhere on the to do list...

denizenging commented 2 years ago

Hi @ocataco,

Do you need them to be able to sign in to the app, or just for agent purposes (such as using them in mutations as provider, receiver, etc.)?

Implementing the second case is quicker because the code for that is implemented already, but just needs to have a GraphQL interface.

Thanks, srfsh

ocataco commented 2 years ago

I want to use it to be able to script reproducible scenarios, where i can do actions on behalf of those agents via the graphql api.

Authentication via the bearer token is a requirement for that i guess? (Because right now i use a username/password combination to get the token...)

denizenging commented 2 years ago

I want to use it to be able to script reproducible scenarios, where i can do actions on behalf of those agents via the graphql api.

Authentication via the bearer token is a requirement for that i guess? (Because right now i use a username/password combination to get the token...)

Yes. The code checks, for example, if the authenticated user is the primary accountable in case if it is used in provider.

denizenging commented 2 years ago

Hi @ocataco,

Can you fetch the latest source and try this make command to create verified users (everything must be set up and this must be run while the application is not running):

make tasks.create_user email="bob@example.com" pass="bobthehunter2"

You can also pass the arguments user to specify the username, name to specify the full name of the user. If not given, those fields will be randomly generated. email and pass fields are required.

An example with all the arguments:

make tasks.create_user email="bob@example.com" pass="bobthehunter2" user="bobby" name="Bob Smith"
ocataco commented 2 years ago

Hi @srfsh,

I have tested and succesfully created a user through the make command locally, thanks!

denizenging commented 2 years ago

Hi @srfsh,

I have tested and succesfully created a user through the make command locally, thanks!

Alright, thanks. I am closing the issue then. ^^