Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

if secret changes, server throws 503 #16

Open
pomidor24 opened this issue Aug 20, 2011 · 1 comment
Open

if secret changes, server throws 503 #16

pomidor24 opened this issue Aug 20, 2011 · 1 comment

Comments

@pomidor24
Copy link

If I change secret, module is not able to handle this and just simply throws.

It would be great to have ability to pass errorCallback to it:

app.use(sessions({
    secret: 'hohoho', 
    session_key: 'FactityBets',
    path: '/',
    timeout: 1000 * 60 * 60 * 24 * 3 // 3 days,
    onError: callback(err, req, res) {
        // code to remove cookie
    }
}));

or as an alternative removeCookieOnError : true

@pomidor24
Copy link
Author

For those who want to go to production with this module. You can remove invalid session with the approach below:

app.use(
    function(req, res, next) {
        try {
            var func = sessions({
                secret: 'hohoho', 
                session_key: 'FactityBets',
                path: '/',
                timeout: 1000 * 60 * 60 * 24 * 3 // 3 days
            });
            func(req, res, next);
        } catch(e) {
            console.log(e);
            res.clearCookie('FactityBets');
            res.redirect('/');
        }
    }
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant