rethinkdb / horizon-docs

Other
24 stars 36 forks source link

Document `hz make-token` and how to boot-strap a user #45

Closed danielmewes closed 8 years ago

danielmewes commented 8 years ago

the hz make-token command is going to be added via https://github.com/rethinkdb/horizon/pull/390

chipotle commented 8 years ago

@deontologician - if it's possible to write up a paragraph or so about how to use this, it'd be really helpful. (cc @Tryneus)

deontologician commented 8 years ago

Hmm, this is actually kinda crappy at the moment. I'm not sure we should document this until rethinkdb/horizon#429 is completed, since otherwise you need to use an internal api I'd rather not suggest in the docs.

I'm going to open another issue in the horizon repo to get some input on how exactly we should get this flow to work, since it's not obvious

deontologician commented 8 years ago

Ok, so now we have rethinkdb/horizon#429 published, so it's ok to talk about it.

Basic process:

  1. With your admin user, do a horizon('users').store({ id: <SOME_USER_ID> })
  2. Now, go to the command line, use hz make-token <SOME_USER_ID> possibly passing connect options to make-token
  3. Copy the token that is printed out on the commandline
  4. Pass that token to your next creation of a Horizon object:
var horizon = Horizon({ authType: { token: <TOKEN_HERE>, storeLocally: true/false }})

token is the user token to log in as storeLocally is whether horizon should try to preserve the token in localStorage so you don't have to pass it the next time you want to log in

danielmewes commented 8 years ago

With your admin user [...]

We'll need to explain that step too (it works as Josh described, just without step 1 and with admin instead of <SOME_USER_ID> in step 2 as far as I know).

deontologician commented 8 years ago

Having to document this is really pointing out how terrible this process is