How to use the express-session.Session function in express-session

To help you get started, we’ve selected a few express-session examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);

                    expect(error).toBeNull();
                    expect(sess.id).toBe('kuXMThISDw9LA7mkEQ0pnOZt');
                    expect(sess.user.name).toBe('guest');

                    sess.user.name = 'test';

                    // set session
                    sut.setSession(sess, function (error, result) {

                        expect(error).toBeNull();
                        expect(result).toBe(true);

                        // get session with new params
                        sut.getSession(cookie, function (error, session) {
                            expect(error).toBeNull();
github litixsoft / baboon / lib / config / socket-io.js View on Github external
baboon.session.getSessionById(socket.request.sessionID, function (error, session) {
            if (error || !session) {
                return next(null, false);
            } else {
                // save session in socket
                socket.request.session = new Session(socket.request, session);

                // restricted socket connection for users with session
                // connect successfully or failed
                return next(null, !!session.user);
            }
        });
    });
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);

                    sess.regenerate = function (callback) {
                        callback();
                    };

                    request = {
                        sessionID: sess.id,
                        session: sess,
                        setSession: function (callback) {
                            callback(null, null);
                        },
                        headers: {}
                    };

                    sut.setActivity({}, request, function (error, result) {
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);

                    expect(error).toBeNull();
                    expect(sess.id).toBe('kuXMThISDw9LA7mkEQ0pnOZt');
                    expect(sess.user.name).toBe('guest');
                    done();
                });
            });
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);
                    sess.user = {
                        name: 'testUser'
                    };
                    sess.loggedIn = true;

                    request = {
                        sessionID: sess.id,
                        session: sess
                    };

                    sut.getUserDataForClient(null, request, function (error, result) {

                        expect(error).toBeNull();
                        expect(result.isLoggedIn).toBe(true);
                        expect(result.username).toBe('testUser');
                        done();
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);

                    request = {
                        sessionID: sess.id,
                        session: sess,
                        setSession: function (callback) {
                            callback(null, true);
                        },
                        headers: {}
                    };

                    sut.setActivity({}, request, function (error, result) {
                        expect(error).toBeNull();
                        expect(result).toBe(true);
                        done();
                    });
                });
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);
                    delete sess.activity;

                    request = {
                        sessionID: sess.id,
                        session: sess
                    };

                    sut.getLastActivity({}, request, function (error, result) {
                        expect(error.message).toBe('Property activity not found in session');
                        expect(result).toBeUndefined();
                        done();
                    });
                });
            });
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {

                    var data = {
                        sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt',
                        sessionStore: sessionStore
                    };

                    var sess = new Session(data, session);
                    delete sess.data;

                    request = {
                        sessionID: sess.id,
                        session: sess
                    };

                    sut.getData({}, request, function (error, result) {
                        expect(error).toBeNull();
                        expect(result).toEqual({});
                        done();
                    });
                });
            });
github litixsoft / baboon / test / session.spec.js View on Github external
sut.getSession(cookie, function (error, session) {
                            expect(error).toBeNull();

                            var sess = new Session({sessionID: 'kuXMThISDw9LA7mkEQ0pnOZt'}, session);

                            expect(sess.id).toBe('kuXMThISDw9LA7mkEQ0pnOZt');
                            expect(sess.user.name).toBe('test');

                            done();
                        });
                    });
github ether / etherpad-lite / src / node / hooks / express / socketio.js View on Github external
args.app.sessionStore.get(data.sessionID, function (err, session) {
        if (err || !session) return accept('Bad session / session has expired', false);
        data.session = new sessionModule.Session(data, session);
        accept(null, true);
      });
    });