@christiansandor/passports
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Passports

Usage

var passports = new Passports();
passports.setConfig(function (request) {
    return {
        instanceId: req.hostname,
        options: {hostname: req.hostname},
    };
});
passports.setInstance(function (options, passport) {
    passport.use(new Strategy(function (username, password, done) {
        done(null, {username: username, host: options.hostname});
    }));

    passport.serializeUser(function (user, cb) {
        cb(null, JSON.stringify(user));
    });

    passport.deserializeUser(function (id, cb) {
        cb(null, JSON.parse(id));
    });
});

app.use(passports.createExpressSession({secret: 'keyboard cat', resave: true, saveUninitialized: false}));
app.use(passports.initialize());
app.use(passports.session());

app.post('/login', passports.authenticate('local', {successRedirect: '/'}));

Readme

Keywords

Package Sidebar

Install

npm i @christiansandor/passports

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

38.8 kB

Total Files

13

Last publish

Collaborators

  • christiansandor