Skip to content

Commit

Permalink
fix spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Carson committed Aug 20, 2013
1 parent ffea643 commit c0c20e6
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions lib/connect-firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module.exports = function (connect) {

this.firebase_url = options.firebase_url;
this.token = options.token;
this.clean_sid = options.clean_sid || function(sid) {
return sid.replace('.', '_');
this.clean_sid = options.clean_sid || function (sid) {
return sid.replace('.', '_');
}

if (this.token) {
Expand All @@ -69,28 +69,28 @@ module.exports = function (connect) {

FirebaseStore.prototype.get = function (sid, fn) {

var self = this;
sid = this.clean_sid(sid);
var self = this;
sid = this.clean_sid(sid);
var now = +new Date;
var sessionRef = new Firebase('https://' + this.firebase_url + '/sessions/' + sid);

sessionRef.once('value', function (snapshot) {
try {
if (!snapshot || snapshot.val() === null) {
return fn(null, null);
} else {
if (!snapshot.val()) return fn(null, null);
else if (snapshot.val().expires && now >= snapshot.val().expires) {
self.destroy(sid, fn);
} else {
var sess = snapshot.val().sess.toString();
sess = JSON.parse(sess);
return fn(null, sess);
}
}
try {
if (!snapshot || snapshot.val() === null) {
return fn(null, null);
} else {
if (!snapshot.val()) return fn(null, null);
else if (snapshot.val().expires && now >= snapshot.val().expires) {
self.destroy(sid, fn);
} else {
var sess = snapshot.val().sess.toString();
sess = JSON.parse(sess);
return fn(null, sess);
}
}
} catch (err) {
fn(err);
}
fn(err);
}
});

};
Expand All @@ -106,17 +106,17 @@ module.exports = function (connect) {

FirebaseStore.prototype.set = function (sid, sess, fn) {

sid = this.clean_sid(sid);
sid = this.clean_sid(sid);
var expires = typeof sess.cookie.maxAge === 'number' ? (+new Date()) + sess.cookie.maxAge : (+new Date()) + oneDayInMilliseconds;
sess_string = JSON.stringify(sess);

var sessionRef = new Firebase('https://' + this.firebase_url + '/sessions/' + sid);
sessionRef.set({
expires: JSON.stringify(expires),
expires: JSON.stringify(expires),
type: 'connect-session',
sess: sess_string
}, fn);

}

/**
Expand All @@ -132,7 +132,7 @@ module.exports = function (connect) {
sid = this.clean_sid(sid);
var sessionRef = new Firebase('https://' + this.firebase_url + '/sessions/' + sid);
sessionRef.remove(fn);

};

return FirebaseStore;
Expand Down

0 comments on commit c0c20e6

Please sign in to comment.