@@ -76,6 +76,7 @@ var Ftp = module.exports = function(cfg) {
7676 this . port = cfg . port || FTP_PORT ;
7777 this . user = cfg . user || 'anonymous' ;
7878 this . pass = cfg . pass || '@anonymous' ;
79+ this . acct = cfg . acct || ''
7980 // True if the server doesn't support the `stat` command. Since listing a
8081 // directory or retrieving file properties is quite a common operation, it is
8182 // more efficient to avoid the round-trip to the server.
@@ -234,7 +235,7 @@ Ftp.prototype.runCommand = function(action, callback) {
234235
235236 var self = this ;
236237 this . getFeatures ( function ( ) {
237- self . auth ( self . user , self . pass , function ( ) {
238+ self . auth ( self . user , self . pass , self . acct , function ( ) {
238239 self . commandQueue . push ( cmd ) ;
239240 self . nextCmd ( ) ;
240241 } ) ;
@@ -316,9 +317,8 @@ Ftp.prototype.getFeatures = function(callback) {
316317 * @param {String } pass Password
317318 * @param {Function } callback Follow-up function.
318319 */
319- Ftp . prototype . auth = function ( user , pass , callback ) {
320+ Ftp . prototype . auth = function ( user , pass , acct , callback ) {
320321 var self = this ;
321-
322322 if ( this . authenticating === true ) {
323323 return callback ( new Error ( 'This client is already authenticating' ) ) ;
324324 }
@@ -329,6 +329,9 @@ Ftp.prototype.auth = function(user, pass, callback) {
329329 if ( ! pass ) {
330330 pass = '@anonymous' ;
331331 }
332+ if ( ! acct ) {
333+ acct = ''
334+ }
332335
333336 this . authenticating = true ;
334337 self . raw ( 'user' , user , function ( err , res ) {
@@ -338,19 +341,23 @@ Ftp.prototype.auth = function(user, pass, callback) {
338341 return ;
339342 }
340343 self . raw ( 'pass' , pass , function ( err , res ) {
341- self . authenticating = false ;
342-
343344 if ( err ) {
345+ self . authenticating = false ;
344346 callback ( err ) ;
345347 } else if ( [ 230 , 202 ] . indexOf ( res . code ) > - 1 ) {
348+ self . authenticating = false ;
346349 self . authenticated = true ;
347350 self . user = user ;
348351 self . pass = pass ;
349352 self . raw ( 'type' , 'I' , function ( ) {
350353 callback ( undefined , res ) ;
351354 } ) ;
352355 } else if ( res . code === 332 ) {
353- self . raw ( 'acct' , '' ) ; // ACCT not really supported
356+ self . raw ( 'acct' , acct , function ( err , res ) {
357+ self . authenticating = false ;
358+ self . authenticated = true ;
359+ callback ( undefined , res )
360+ } ) ; // ACCT not really supported
354361 }
355362 } ) ;
356363 } ) ;
0 commit comments