Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-session-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-session-mongodb - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

33

lib/ExpressSessionMongoDB.js

@@ -183,2 +183,22 @@ //Copyright (c) 2014 Eric Vallee <eric_vallee2003@yahoo.ca>

function GetSessionInfo(Session, SessionCollection, SessionID, Callback)
{
var Self = this;
if(Session && Session.Delete)
{
SessionCollection.remove({'SessionID': SessionID}, function(Err, Result) {
Callback(Err, null);
});
}
else
{
var Data = Session ? Session.Data : null;
Data = Data && Self.Filter ? Filter(Data, true) : Data;
if(Callback)
{
Callback(null, Data);
}
}
}
Store.prototype.get = function(SessionID, Callback) {

@@ -194,8 +214,3 @@ var Self = this;

HandleError(Err, Callback, function() {
var Data = Session ? Session.Data : null;
Data = Data && Self.Filter ? Filter(Data, true) : Data;
if(Callback)
{
Callback(null, Data);
}
GetSessionInfo.call(Self, Session, SessionCollection, SessionID, Callback);
});

@@ -209,7 +224,3 @@ });

HandleError(Err, Callback, function() {
var Data = Session ? Session.Data : null;
if(Callback)
{
Callback(null, Data);
}
GetSessionInfo.call(Self, Session, SessionCollection, SessionID, Callback);
});

@@ -216,0 +227,0 @@ })

{
"name": "express-session-mongodb",
"version": "1.1.1",
"version": "1.2.0",
"description": "Session Store for express-session",

@@ -5,0 +5,0 @@ "keywords": [

@@ -144,1 +144,9 @@ ExpressSessionMongoDB

- Added TimeToLive tests.
1.1.2
-----
- A small bit of refactoring in code and integration tests
- Fixed a bug where the Filter option wouldn't be applied if the TimeToLive option is greater than 0
- Added a facility for the get accessor to delete a session when fetching it if it is flaged to be deleted.
- Added integration test for the above.

@@ -310,14 +310,12 @@ //Copyright (c) 2014 Eric Vallee <eric_vallee2003@yahoo.ca>

var Handler = new RequestHandler();
Context['DB'].collection('Sessions', function(Err, SessionsCollection) {
Handler.Request('PUT', '/FlagDelete', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('POST', '/Test/Increment', false, function() {
Test.ok(Handler.SessionID==InitialSessionID, "Confirming that express-session saved the in-memory data, re-creating the session in the database.");
Test.ok(!Context['LastError'], "Confirming that usual get is error-free in the absense of the session in storage.");
Handler.Request('POST', '/Test/Increment', false, function() {
Test.ok(Handler.SessionID==InitialSessionID, "Confirming that express-session saved the in-memory data, re-creating the session in the database.");
Test.ok(!Context['LastError'], "Confirming that usual get is error-free in the absense of the session in storage.");
Handler.Request('POST', '/Test/Increment', false, function() {
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(Body['Value']==2, "Confirming that session data was preserved.");
Test.ok(Handler.SessionID==InitialSessionID, "Re-Confirming that express-session saved the in-memory data, re-creating the session in the database.");
Test.done();
});
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(Body['Value']==2, "Confirming that session data was preserved.");
Test.ok(Handler.SessionID==InitialSessionID, "Re-Confirming that express-session saved the in-memory data, re-creating the session in the database.");
Test.done();
});

@@ -331,11 +329,9 @@ });

var Handler = new RequestHandler();
Context['DB'].collection('Sessions', function(Err, SessionsCollection) {
Handler.Request('POST', '/Test/Increment', false, function() {
Handler.Request('PUT', '/FlagDelete', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/Session/Regeneration', false, function() {
Test.ok(!Context['LastError'], "Confirming that session regeneration is error-free in the absense of the session in storage.");
Test.ok(Handler.SessionID!=InitialSessionID, "Confirming that the session was regenerated.");
Test.done();
});
Handler.Request('POST', '/Test/Increment', false, function() {
Handler.Request('PUT', '/FlagDelete', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/Session/Regeneration', false, function() {
Test.ok(!Context['LastError'], "Confirming that session regeneration is error-free in the absense of the session in storage.");
Test.ok(Handler.SessionID!=InitialSessionID, "Confirming that the session was regenerated.");
Test.done();
});

@@ -348,13 +344,11 @@ });

var Handler = new RequestHandler();
Context['DB'].collection('Sessions', function(Err, SessionsCollection) {
Handler.Request('POST', '/Test/Increment', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
Handler.Request('PUT', '/Session/Destruction', false, function() {
Test.ok(!Context['LastError'], "Confirming that session destruction is error-free in the absense of the session in storage.");
Test.ok(Handler.SessionID == InitialSessionID, "Confirming that a new session ID has not been generated.");
Handler.Request('POST', '/Test/Increment', false, function() {
Test.ok(Handler.SessionID != InitialSessionID, "Confirming that a new session ID has been generated.");
Test.done();
});
Handler.Request('POST', '/Test/Increment', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
Handler.Request('PUT', '/Session/Destruction', false, function() {
Test.ok(!Context['LastError'], "Confirming that session destruction is error-free in the absense of the session in storage.");
Test.ok(Handler.SessionID == InitialSessionID, "Confirming that a new session ID has not been generated.");
Handler.Request('POST', '/Test/Increment', false, function() {
Test.ok(Handler.SessionID != InitialSessionID, "Confirming that a new session ID has been generated.");
Test.done();
});

@@ -368,14 +362,12 @@ });

var Handler = new RequestHandler();
Context['DB'].collection('Sessions', function(Err, SessionsCollection) {
Handler.Request('POST', '/Test/Increment', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
Handler.Request('PUT', '/Session/Reload/Test', false, function() {
Test.ok(Context['LastError'], "Confirming that reload returned an error");
Test.ok(Handler.SessionID == InitialSessionID, "Confirming that a new session ID has not been generated.");
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(Handler.SessionID == InitialSessionID, "Re-confirming that a new session ID has not been generated.");
Test.ok(Body['Value']==2, "Confirming that the session data from memory was preserved.");
Test.done();
});
Handler.Request('POST', '/Test/Increment', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
Handler.Request('PUT', '/Session/Reload/Test', false, function() {
Test.ok(Context['LastError'], "Confirming that reload returned an error");
Test.ok(Handler.SessionID == InitialSessionID, "Confirming that a new session ID has not been generated.");
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(Handler.SessionID == InitialSessionID, "Re-confirming that a new session ID has not been generated.");
Test.ok(Body['Value']==2, "Confirming that the session data from memory was preserved.");
Test.done();
});

@@ -389,12 +381,39 @@ });

var Handler = new RequestHandler();
Handler.Request('POST', '/Test/Increment', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
Handler.Request('PUT', '/Session/Save/Test', false, function() {
Test.ok(!Context['LastError'], "Confirming that save didn't encounter an error.");
Test.ok(Handler.SessionID == InitialSessionID, "Confirming that a new session ID has not been generated.");
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(Handler.SessionID == InitialSessionID, "Re-confirming that a new session ID has not been generated.");
Test.ok(Body['Value']==2, "Confirming that the session data was preserved.");
Test.done();
});
});
});
});
}
};
exports.Delete = {
'setUp': function(Callback) {
Setup({'secret': 'qwerty!'}, Callback, {'TimeToLive': 2});
},
'tearDown': function(Callback) {
TearDown(Callback);
},
'TestMain': function(Test) {
Test.expect(4);
var Handler = new RequestHandler();
Context['DB'].collection('Sessions', function(Err, SessionsCollection) {
Handler.Request('POST', '/Test/Increment', false, function() {
var InitialSessionID = Handler.SessionID;
Handler.Request('PUT', '/FlagDelete', false, function() {
Handler.Request('PUT', '/Session/Save/Test', false, function() {
Test.ok(!Context['LastError'], "Confirming that save didn't encounter an error.");
Test.ok(Handler.SessionID == InitialSessionID, "Confirming that a new session ID has not been generated.");
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(Handler.SessionID == InitialSessionID, "Re-confirming that a new session ID has not been generated.");
Test.ok(Body['Value']==2, "Confirming that the session data was preserved.");
SessionsCollection.update({}, {'$set': {'Delete': true}}, function(Err, Result) {
Handler.Request('GET', '/Test', true, function(Body) {
Test.ok(!Context['LastError'], "Confirming that the process was error-free.");
Test.ok(Handler.SessionID != InitialSessionID, "Confirming that a new session ID has been generated.");
Test.ok(!Body['Value'], "Confirming that the session data didn't survive transition.");
SessionsCollection.findOne({'SessionID': InitialSessionID}, function(Err, Session) {
Test.ok(!Session, "Confirming that previous session was wiped out from database.");
Test.done();

@@ -401,0 +420,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc