rethinkdb password for user from Node.js

953 views Asked by At

I have successfully configured a user "bob" to use the password "secret" in rethinkdb:

r.db('rethinkdb').table('users').insert({id: 'bob', password: 'secret'})

From Node.js, I'm trying to connect to it using npm's rethinkdb module.

r.connect({ host: 'backend', port: 28015, db: 'db', user: 'bob', password: 'secret' });

I get the following error regarding the password:

Unhandled rejection ReqlAuthError: Wrong password

Without a password on rethinkdb, the connection succeeds, so there is no connectivity issue. With a different username, I get the expected "unknown user" error... do I get a hash for the password when I create it on rethinkdb? Any idea?

1

There are 1 answers

10
C.Unbay On BEST ANSWER

From the rethinkDB docs.

password: the password for the user account to connect as (default "", empty).

Important: You can update a password of a user after you connect to the database.

You can remove a password with the line of code, by using update methoed and setting the password to false value.

r.db('rethinkdb').table('users').get('bob').update({password: false})

You can change a password of a user by using insert method. Here is an example.

r.db('rethinkdb').table('users').insert({id: 'bob', password: 'secret'})