@@ -42,8 +42,8 @@ module.exports = function (connect) {
4242
4343 this . firebase_url = options . firebase_url ;
4444 this . token = options . token ;
45- this . clean_sid = options . clean_sid || function ( sid ) {
46- return sid . replace ( '.' , '_' ) ;
45+ this . clean_sid = options . clean_sid || function ( sid ) {
46+ return sid . replace ( '.' , '_' ) ;
4747 }
4848
4949 if ( this . token ) {
@@ -69,28 +69,28 @@ module.exports = function (connect) {
6969
7070 FirebaseStore . prototype . get = function ( sid , fn ) {
7171
72- var self = this ;
73- sid = this . clean_sid ( sid ) ;
72+ var self = this ;
73+ sid = this . clean_sid ( sid ) ;
7474 var now = + new Date ;
7575 var sessionRef = new Firebase ( 'https://' + this . firebase_url + '/sessions/' + sid ) ;
7676
7777 sessionRef . once ( 'value' , function ( snapshot ) {
78- try {
79- if ( ! snapshot || snapshot . val ( ) === null ) {
80- return fn ( null , null ) ;
81- } else {
82- if ( ! snapshot . val ( ) ) return fn ( null , null ) ;
83- else if ( snapshot . val ( ) . expires && now >= snapshot . val ( ) . expires ) {
84- self . destroy ( sid , fn ) ;
85- } else {
86- var sess = snapshot . val ( ) . sess . toString ( ) ;
87- sess = JSON . parse ( sess ) ;
88- return fn ( null , sess ) ;
89- }
90- }
78+ try {
79+ if ( ! snapshot || snapshot . val ( ) === null ) {
80+ return fn ( null , null ) ;
81+ } else {
82+ if ( ! snapshot . val ( ) ) return fn ( null , null ) ;
83+ else if ( snapshot . val ( ) . expires && now >= snapshot . val ( ) . expires ) {
84+ self . destroy ( sid , fn ) ;
85+ } else {
86+ var sess = snapshot . val ( ) . sess . toString ( ) ;
87+ sess = JSON . parse ( sess ) ;
88+ return fn ( null , sess ) ;
89+ }
90+ }
9191 } catch ( err ) {
92- fn ( err ) ;
93- }
92+ fn ( err ) ;
93+ }
9494 } ) ;
9595
9696 } ;
@@ -106,17 +106,17 @@ module.exports = function (connect) {
106106
107107 FirebaseStore . prototype . set = function ( sid , sess , fn ) {
108108
109- sid = this . clean_sid ( sid ) ;
109+ sid = this . clean_sid ( sid ) ;
110110 var expires = typeof sess . cookie . maxAge === 'number' ? ( + new Date ( ) ) + sess . cookie . maxAge : ( + new Date ( ) ) + oneDayInMilliseconds ;
111111 sess_string = JSON . stringify ( sess ) ;
112112
113113 var sessionRef = new Firebase ( 'https://' + this . firebase_url + '/sessions/' + sid ) ;
114114 sessionRef . set ( {
115- expires : JSON . stringify ( expires ) ,
115+ expires : JSON . stringify ( expires ) ,
116116 type : 'connect-session' ,
117117 sess : sess_string
118118 } , fn ) ;
119-
119+
120120 }
121121
122122 /**
@@ -132,7 +132,7 @@ module.exports = function (connect) {
132132 sid = this . clean_sid ( sid ) ;
133133 var sessionRef = new Firebase ( 'https://' + this . firebase_url + '/sessions/' + sid ) ;
134134 sessionRef . remove ( fn ) ;
135-
135+
136136 } ;
137137
138138 return FirebaseStore ;
0 commit comments