• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript passport.session函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript passport.use函数代码示例发布时间:2022-05-25
下一篇:
TypeScript passport.serializeUser函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap