Skip to content

Commit d3023bd

Browse files
author
Nighelles
committed
Fixing javascript driver for #5659
This should allow both `user` and `username` Review by @josh and @VeXocide
1 parent 239c958 commit d3023bd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

net.coffee

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,16 +1000,16 @@ class TcpConnection extends Connection
10001000

10011001
r_string = new Buffer(crypto.randomBytes(18)).toString('base64')
10021002

1003-
@rawSocket.username = host["username"]
1003+
@rawSocket.user = host["user"]
10041004
@rawSocket.password = host["password"]
10051005

10061006
# Default to admin user with no password if none is given.
1007-
if @rawSocket.username is undefined
1008-
@rawSocket.username = "admin"
1007+
if @rawSocket.user is undefined
1008+
@rawSocket.user = "admin"
10091009
if @rawSocket.password is undefined
10101010
@rawSocket.password = ""
10111011

1012-
client_first_message_bare = "n=" + @rawSocket.username + ",r=" + r_string
1012+
client_first_message_bare = "n=" + @rawSocket.user + ",r=" + r_string
10131013

10141014
message = JSON.stringify({
10151015
protocol_version: protoVersionNumber,
@@ -1636,11 +1636,17 @@ module.exports.connect = varar 0, 2, (hostOrCallback, callback) ->
16361636
# 2. Initializes the connection, and when it's complete invokes
16371637
# the user's callback
16381638
new Promise( (resolve, reject) ->
1639-
if host.authKey? && (host.password? || host.user?)
1639+
if host.authKey? && (host.password? || host.user? || host.username?)
16401640
throw new err.ReqlDriverError "Cannot use both authKey and password"
1641+
if host.user && host.username
1642+
throw new err.ReqlDriverError "Cannot use both user and username"
16411643
else if host.authKey
16421644
host.user = "admin"
16431645
host.password = host.authKey
1646+
else
1647+
# Fixing mismatch between drivers
1648+
if host.username?
1649+
host.user = host.username
16441650
create_connection = (host, callback) =>
16451651
if TcpConnection.isAvailable()
16461652
new TcpConnection host, callback

0 commit comments

Comments
 (0)