當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript passport.session函數代碼示例

本文整理匯總了TypeScript中passport.session函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript session函數的具體用法?TypeScript session怎麽用?TypeScript session使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了session函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: start

  start() {
    let app: express.Express = express();
    app.use('/', express.static('public'));
    var upload: multer.Instance = multer(); // for parsing multipart/form-data

    //Server Middlewares configuration part
    app.use(allowCrossDomain);
    app.use(cookieParser()); // read cookies (needed for auth)
    app.use(bodyParser.json()); // for parsing application/json
    app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
    app.use(expressSession({secret: 'swcmi'}));

    

    //To use passport 
    app.use(passport.initialize());
    app.use(passport.session()); // persistent login sessions

    //start router
    this.apiRouter.init(app);


    //port
    app.listen(10000, function () {
      console.log('SuWon church API Server listening on port 10000!')
    });

  }
開發者ID:jcdby,項目名稱:SuwonCMIAPIServer,代碼行數:28,代碼來源:server.ts

示例2: initialize

 public initialize(router: express.Router): void {
     router.use(passport.initialize());
     const useSession = _.get(this.options, 'authOptions.session', true);
     if (useSession) {
         router.use(passport.session());
         if (this.options.serializeUser && this.options.deserializeUser) {
             passport.serializeUser((user: any, done: (a: any, b: string) => void) => {
                 Promise.resolve(this.options.serializeUser(user))
                     .then((result: string) => {
                         done(null, result);
                     }).catch((err: Error) => {
                         done(err, null);
                     });
             });
             passport.deserializeUser((user: string, done: (a: any, b: any) => void) => {
                 Promise.resolve(this.options.deserializeUser(user))
                     .then((result: any) => {
                         done(null, result);
                     }).catch((err: Error) => {
                         done(err, null);
                     });
             });
         }
     }
 }
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:25,代碼來源:passport.ts

示例3: express

 return new Promise<void>((resolve, reject) => {
     let app: express.Application = express();
     app.set('env', 'test');
     PassportInitialize();
     app.use(Passport.initialize());
     app.use(Passport.session());
     Server.passportAuth('jwt', 'roles');
     Server.setFileLimits({
         fieldSize: 1024 * 1024
     });
     Server.loadControllers(app, ['test/data/*', '!**/*.yaml'], `${__dirname}/../..`);
     Server.setParamConverter((value, type) => {
         if (type.name === 'Person' && value['salary'] === 424242) {
             value['salary'] = 434343;
         }
         return value;
     });
     Server.swagger(app, './test/data/swagger.yaml', 'api-docs', 'localhost:5674', ['http']);
     server = app.listen(5674, (err: any) => {
         if (err) {
             return reject(err);
         }
         resolve();
     });
 });
開發者ID:garyevari,項目名稱:typescript-rest,代碼行數:25,代碼來源:test.spec.ts

示例4: async

export const start = async (port: string) => {
  await MongooseClient.InitMongoConnection();

  const app = express();
  const appRootUrl = siteName ? `https://${siteName}.azurewebsites.net` : `http://localhost:${port}`;

  initPassport(appRootUrl);
  enableSessions(app, SocketServer);
  initSockets();
  app.use(json())
  app.use(passport.initialize());
  app.use(passport.session());
  const server = createServer(app);
  SocketServer.attach(server);

  app.use(Routes);

  await new Promise(resolve => {
    server.listen(port, () => {
      console.log(`Server listening at port ${port}`);
      resolve()
    });
  })

  return async function close() {
    await new Promise(resolve => server.close(resolve))
    await MongooseClient.disconnect()
  }
};
開發者ID:Majavapaja,項目名稱:Mursushakki,代碼行數:29,代碼來源:app.ts

示例5: require

    app.configure(function(){
        app.engine('html', require('ejs').renderFile);
        app.set('view engine', 'html');
        app.use(express.logger('dev'));
        app.use(express.json());
        app.use(express.urlencoded());
        app.use(express.methodOverride());
        app.use(express.cookieParser());

        // Persist sessions with mongoStore
        app.use(express.session({
            secret: 'angular-fullstack secret',
            /*
            store: new mongoStore({
                url: config.mongo.uri,
                collection: 'sessions'
            }, function () {
                console.log("db connection open");
            })
            */
        }));

        //use passport session
        app.use(passport.initialize());
        app.use(passport.session());

        // Router (only error handlers should come after this)
        app.use(app.router);
    });
開發者ID:swcho,項目名稱:ex_ossdb,代碼行數:29,代碼來源:express.ts

示例6: constructor

        constructor() {

            var session = require('cookie-session');
            var flash = require('flash');

            var app = express();

            app.use(express.static('build/client'));
            app.use('/server', express.static('server'));
            app.use('/client', express.static('client'));
            app.use('/bower_components', express.static('bower_components'));
            app.use('/node_modules', express.static('node_modules'));

            app.use(cookieParser());
            app.use(session({ secret: 'victoriasecret', resave: true, saveUninitialized: true }));
            app.use(passport.initialize());
            app.use(passport.session());
            app.use(bodyParser.json());
            app.use(bodyParser.urlencoded({ extended: true }));
            app.use('/api/auth', Auth());

            Database.init('test');
            Passport.init();

            app.listen(3000);
        }
開發者ID:zzeneg,項目名稱:NodeSimpleWebsite,代碼行數:26,代碼來源:server.ts

示例7:

app.configure(function () {
    app.use(express.static('public'));
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.session({ secret: 'keyboard cat' }));
    app.use(passport.initialize());
    app.use(passport.session());
    app.use(app.router);
});
開發者ID:dpwolfe,項目名稱:nko4-siecieborowice,代碼行數:9,代碼來源:server.ts

示例8: initAuth

function initAuth() {
    const flash = require('connect-flash');
    app.use(flash());

    const passport = require('passport');

    auth(passport);

    app.use(passport.initialize());
    app.use(passport.session()); // persistent login sessions

    return passport;
}
開發者ID:yegor-sytnyk,項目名稱:contoso-express,代碼行數:13,代碼來源:server.ts

示例9: enableSessionSelialization

module.exports = (app: express.Express) => {
  // Initialize passport
  app.use(passport.initialize());
  app.use(passport.session());

  enableSessionSelialization();

  // Load strategies
  let strategiesPath = path.normalize(__dirname + '/passport/strategy');
  let auth = glob.sync(strategiesPath + '/*.+(js|ts|jsx|tsx)');
  auth.forEach(function (routes) {
    require(routes)(app);
  });
};
開發者ID:toannvbk93,項目名稱:goemon,代碼行數:14,代碼來源:passport.ts

示例10: expressConfig

function expressConfig(app) {
    app.use(compress({
        filter: function (req, res) {
            return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
        },
        level: 9
    }));

    app.set('views', path.join(__dirname, '../app/views'));
    app.set('view engine', 'jade');
    app.use(logger('dev'));
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded());
    app.use(cookieParser());
    app.use(express.static(path.join(__dirname, '../public')));

    // express/mongo session storage
    app.use(session({
        secret: 'd@s !t m@n#',
        store: new mongoStore({
            url: config.db,
            collection: 'sessions'
        })
    }));

    // use passport session
    app.use(passport.initialize());
    app.use(passport.session());

    app.use(flash());

    app.use('/', routes);

    app.use(function (req, res, next) {
        var err = new Error('Not Found');
        //err.status = 404;
        next(err);
    });

    // production error handler
    // no stacktraces leaked to user
    app.use(function (err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: {}
        });
    });
}
開發者ID:anweiss,項目名稱:PlatyNEM,代碼行數:49,代碼來源:express.ts


注:本文中的passport.session函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。