File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -10,24 +10,34 @@ function SessionManager(options, serializeUser) {
1010}
1111
1212SessionManager . prototype . logIn = function ( req , user , cb ) {
13+ console . log ( 'SM: logIn' ) ;
14+
1315 var self = this ;
14- this . _serializeUser ( user , req , function ( err , obj ) {
16+ req . session . regenerate ( function ( err ) {
1517 if ( err ) {
1618 return cb ( err ) ;
1719 }
18- // TODO: Error if session isn't available here.
19- if ( ! req . session ) {
20- req . session = { } ;
21- }
22- if ( ! req . session [ self . _key ] ) {
23- req . session [ self . _key ] = { } ;
24- }
25- req . session [ self . _key ] . user = obj ;
26- cb ( ) ;
20+
21+ self . _serializeUser ( user , req , function ( err , obj ) {
22+ if ( err ) {
23+ return cb ( err ) ;
24+ }
25+ // TODO: Error if session isn't available here.
26+ if ( ! req . session ) {
27+ req . session = { } ;
28+ }
29+ if ( ! req . session [ self . _key ] ) {
30+ req . session [ self . _key ] = { } ;
31+ }
32+ req . session [ self . _key ] . user = obj ;
33+ cb ( ) ;
34+ } ) ;
2735 } ) ;
2836}
2937
3038SessionManager . prototype . logOut = function ( req , cb ) {
39+ console . log ( 'SM: logOut' ) ;
40+
3141 if ( req . session && req . session [ this . _key ] ) {
3242 delete req . session [ this . _key ] . user ;
3343 }
You can’t perform that action at this time.
0 commit comments