@@ -199,36 +199,35 @@ class Client extends EventEmitter {
199
199
// TODO(bmc): deprecate pgpass "built in" integration since this.password can be a function
200
200
// it can be supplied by the user if required - this is a breaking change!
201
201
_checkPgPass ( cb ) {
202
- return function ( msg ) {
203
- if ( typeof this . password === 'function' ) {
204
- this . _Promise
205
- . resolve ( )
206
- . then ( ( ) => this . password ( ) )
207
- . then ( ( pass ) => {
208
- if ( pass !== undefined ) {
209
- if ( typeof pass !== 'string' ) {
210
- con . emit ( 'error' , new TypeError ( 'Password must be a string' ) )
211
- return
212
- }
213
- this . connectionParameters . password = this . password = pass
214
- } else {
215
- this . connectionParameters . password = this . password = null
202
+ const con = this . connection
203
+ if ( typeof this . password === 'function' ) {
204
+ this . _Promise
205
+ . resolve ( )
206
+ . then ( ( ) => this . password ( ) )
207
+ . then ( ( pass ) => {
208
+ if ( pass !== undefined ) {
209
+ if ( typeof pass !== 'string' ) {
210
+ con . emit ( 'error' , new TypeError ( 'Password must be a string' ) )
211
+ return
216
212
}
217
- cb ( msg )
218
- } )
219
- . catch ( ( err ) => {
220
- con . emit ( 'error' , err )
221
- } )
222
- } else if ( this . password !== null ) {
223
- cb ( msg )
224
- } else {
225
- pgPass ( this . connectionParameters , function ( pass ) {
226
- if ( undefined !== pass ) {
227
213
this . connectionParameters . password = this . password = pass
214
+ } else {
215
+ this . connectionParameters . password = this . password = null
228
216
}
229
- cb ( msg )
217
+ cb ( )
230
218
} )
231
- }
219
+ . catch ( ( err ) => {
220
+ con . emit ( 'error' , err )
221
+ } )
222
+ } else if ( this . password !== null ) {
223
+ cb ( )
224
+ } else {
225
+ pgPass ( this . connectionParameters , function ( pass ) {
226
+ if ( undefined !== pass ) {
227
+ this . connectionParameters . password = this . password = pass
228
+ }
229
+ cb ( )
230
+ } )
232
231
}
233
232
}
234
233
@@ -239,14 +238,14 @@ class Client extends EventEmitter {
239
238
}
240
239
241
240
_handleAuthMD5Password ( msg ) {
242
- this . _checkPgPass ( ( msg ) => {
241
+ this . _checkPgPass ( ( ) => {
243
242
const hashedPassword = utils . postgresMd5PasswordHash ( this . user , this . password , msg . salt )
244
243
this . connection . password ( hashedPassword )
245
244
} )
246
245
}
247
246
248
- _handleAuthSASL ( msg ) {
249
- this . _checkPgPass ( ( msg ) => {
247
+ _handleAuthSASL ( ) {
248
+ this . _checkPgPass ( ( ) => {
250
249
this . saslSession = sasl . startSession ( msg . mechanisms )
251
250
const con = this . connection
252
251
con . sendSASLInitialResponseMessage ( saslSession . mechanism , saslSession . response )
0 commit comments