@@ -367,6 +367,7 @@ RestWrite.prototype.transformUser = function() {
367
367
}
368
368
if ( this . query && ! this . auth . isMaster ) {
369
369
this . storage [ 'clearSessions' ] = true ;
370
+ this . storage [ 'generateNewSession' ] = true ;
370
371
}
371
372
return passwordCrypto . hash ( this . data . password ) . then ( ( hashedPassword ) => {
372
373
this . data . _hashed_password = hashedPassword ;
@@ -428,6 +429,10 @@ RestWrite.prototype.createSessionTokenIfNeeded = function() {
428
429
if ( this . query ) {
429
430
return ;
430
431
}
432
+ return this . createSessionToken ( ) ;
433
+ }
434
+
435
+ RestWrite . prototype . createSessionToken = function ( ) {
431
436
var token = 'r:' + cryptoUtils . newToken ( ) ;
432
437
433
438
var expiresAt = this . config . generateSessionExpiresAt ( ) ;
@@ -464,15 +469,21 @@ RestWrite.prototype.handleFollowup = function() {
464
469
}
465
470
} ;
466
471
delete this . storage [ 'clearSessions' ] ;
467
- this . config . database . destroy ( '_Session' , sessionQuery )
472
+ return this . config . database . destroy ( '_Session' , sessionQuery )
473
+ . then ( this . handleFollowup . bind ( this ) ) ;
474
+ }
475
+
476
+ if ( this . storage && this . storage [ 'generateNewSession' ] ) {
477
+ delete this . storage [ 'generateNewSession' ] ;
478
+ return this . createSessionToken ( )
468
479
. then ( this . handleFollowup . bind ( this ) ) ;
469
480
}
470
481
471
482
if ( this . storage && this . storage [ 'sendVerificationEmail' ] ) {
472
483
delete this . storage [ 'sendVerificationEmail' ] ;
473
484
// Fire and forget!
474
485
this . config . userController . sendVerificationEmail ( this . data ) ;
475
- this . handleFollowup . bind ( this ) ;
486
+ return this . handleFollowup . bind ( this ) ;
476
487
}
477
488
} ;
478
489
0 commit comments