2

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?

dgulabs
  • 443
  • 4
  • 16
  • hi, i have same problem and it isn't clear how you resolved it from the comments. can you elaborate how you fixed it. All i want is able to connect with user 'bob' and password 'secret' – uma mahesh May 22 '18 at 11:45

1 Answers1

1

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'})
Ahmed Can Unbay
  • 2,694
  • 2
  • 16
  • 33
  • The password has been set succesfully from Rethinkdb's administration console. The problem is how I connect to it from Node.js. – dgulabs Sep 07 '17 at 18:56
  • hmm so the problem states itself, you can't set the password right, if you could, it still wouldn't have been empty @dgulabs let me check on solutions for it – Ahmed Can Unbay Sep 07 '17 at 19:03
  • so you can connect to the db with this command : `r.connect({ host: 'backend', port: 28015, db: 'db', user: 'bob' });` am I right? Have you tried to run the `insert` function after you have connected? so `insert` should come after `connect` – Ahmed Can Unbay Sep 07 '17 at 19:05
  • I cannot connect without a password, given that the user is successfully inserted with a password (the insert() from the administration console works successfully and indicates that 'bob' has a password). The problem is that 'secret' doesn't seem to be a valid password... – dgulabs Sep 07 '17 at 19:07
  • 1
    interesting, so the password value does not work... after you have created the user try to update the password by using this then, `r.db('rethinkdb').table('users').get('bob').update({password: "myPassword"})` – Ahmed Can Unbay Sep 07 '17 at 19:12
  • and then run it again @dgulabs – Ahmed Can Unbay Sep 07 '17 at 19:15
  • what have you gotten? @dgulabs – Ahmed Can Unbay Sep 07 '17 at 19:21
  • Ok, it seems to work if I don't have a password for the admin account (specified through --initial-password for rethinkdb). If the admin account has no password, I can use my custom user. Weird. – dgulabs Sep 07 '17 at 19:27
  • are you having the same problem with admin account? has your problem been solved? – Ahmed Can Unbay Sep 07 '17 at 19:30
  • It's fixed, but if I set a password for the admin account, a non-admin user cannot login. But I consider it fixed for my current case. Thanks a lot!. – dgulabs Sep 07 '17 at 19:37