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

TypeScript passport.authenticate函数代码示例

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

本文整理汇总了TypeScript中passport.authenticate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript authenticate函数的具体用法?TypeScript authenticate怎么用?TypeScript authenticate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了authenticate函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: configureLocal

	private configureLocal() {
		// show the login form
		this.app.get("/login", (req: any, res: any) => {
            res.render("frontoffice/login", { message: req.flash("loginMessage") });
        });

		// process the login form
        this.app.post("/login", passport.authenticate("local-login", {
            successRedirect: "/profile", // redirect to the secure profile section
            failureRedirect: "/login", // redirect back to the signup page if there is an error
            failureFlash: true, // allow flash messages
        }));

		// show the signup form
        this.app.get("/signup", (req: any, res: any) => {
            res.render("frontoffice/singup", { message: req.flash("signupMessage") });
        });

        // process the signup form
        this.app.post("/signup", passport.authenticate("local-signup", {
            successRedirect: "/profile", // redirect to the secure profile section
            failureRedirect: "/signup", // redirect back to the signup page if there is an error
            failureFlash: true, // allow flash messages
        }));
	}
开发者ID:Event-Starter-Kit,项目名称:website,代码行数:25,代码来源:002.authentication.ts


示例2: function

var router = function () {
    // GET /auth/linkedin
    //   Use passport.authenticate() as route middleware to authenticate the
    //   request.  The first step in LinkedIn authentication will involve
    //   redirecting the user to linkedin.com.  After authorization, LinkedIn will
    //   redirect the user back to this application at /auth/linkedin/callback
    linkedInRouter.route('/linkedin').get(
        passport.authenticate('linkedin'),
        function (req, res) {
            // The request will be redirected to LinkedIn for authentication, so this
            // function will not be called.
        });

    // GET /auth/linkedin/callback
    //   Use passport.authenticate() as route middleware to authenticate the
    //   request.  If authentication fails, the user will be redirected back to the
    //   login page.  Otherwise, the primary route function function will be called,
    //   which, in this example, will redirect the user to the home page.
    linkedInRouter.route('/linkedin/callback').get(
        passport.authenticate('linkedin', { failureRedirect: '/login' }),
        function (req, res) {
            res.redirect('/');
        });

    linkedInRouter.route('/linkedin/logout').get(
        function(req, res) {
            req.logout();
            res.redirect('/');
        });

    return linkedInRouter;
}
开发者ID:thekj,项目名称:berlin_sandbox,代码行数:32,代码来源:linkedin.routes.ts


示例3: Auth

export default function Auth(): express.Router {

    var router = express.Router();

    router.get('/', (req, res) => {
        if (req.user) {
            res.json(req.user);
        }
        else {
            res.status(401);
        }

    });

    router.post('/signup', passport.authenticate('local-signup'), (req, res) => { res.json(req.user) });

    router.post('/login', passport.authenticate('local-login'), (req, res) => { res.json(req.user); });

    router.get('/logout', (req, res) => {
        req.logout();
        res.redirect('/');
    });

    router.get('/twitter', passport.authenticate('twitter'));

    // handle the callback after twitter has authenticated the user
    router.get('/twitter/callback', passport.authenticate('twitter', { successRedirect: '/', failureRedirect: '/' }));

    return router;
}
开发者ID:zzeneg,项目名称:NodeSimpleWebsite,代码行数:30,代码来源:auth.ts


示例4: init

export function init(app: Express) {
  // Rutas del controlador
  app.route("/province")
    .get(province.list)
    .put(passport.authenticate("jwt", { session: false }), security.validateAdminRole, province.validateUpdate, province.update);

  app.route("/province/:provinceId")
    .get(province.findByID, province.read)
    .delete(passport.authenticate("jwt", { session: false }), security.validateAdminRole, province.findByID, province.validateUpdate, province.remove);
}
开发者ID:maticorv,项目名称:mascotas2018_foro,代码行数:10,代码来源:module.ts


示例5: configureGoogle

	private configureGoogle(): void {
		// send to google to do the authentication
        this.app.get("/auth/google", passport.authenticate("google", { scope: ["profile", "email"] }));

        // the callback after google has authenticated the user
        this.app.get("/auth/google/callback",
            passport.authenticate("google", {
                failureRedirect: "/",
                successRedirect: "/auth/userInfo",
            }));
	}
开发者ID:Event-Starter-Kit,项目名称:website,代码行数:11,代码来源:002.authentication.ts


示例6: configureTwitter

	private configureTwitter(): void {
		// send to twitter to do the authentication
        this.app.get("/auth/twitter", passport.authenticate("twitter", { scope: "email" }));

        // handle the callback after twitter has authenticated the user
        this.app.get("/auth/twitter/callback",
            passport.authenticate("twitter", {
				failureRedirect: "/",
                successRedirect: "/auth/userInfo",
            }));
	}
开发者ID:Event-Starter-Kit,项目名称:website,代码行数:11,代码来源:002.authentication.ts


示例7: configureFacebook

	private configureFacebook(): void {
		// send to facebook to do the authentication
        this.app.get("/auth/facebook", passport.authenticate("facebook", { scope: "email" }));

        // handle the callback after facebook has authenticated the user
        this.app.get("/auth/facebook/callback",
            passport.authenticate("facebook", {
                failureRedirect: "/",
                successRedirect: "/auth/userInfo",
            }));
	}
开发者ID:Event-Starter-Kit,项目名称:website,代码行数:11,代码来源:002.authentication.ts


示例8: addRoutes

    private addRoutes() {
        this.facebookAuthentication();
        // route for facebook authentication and login
        router.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));

        // handle the callback after facebook has authenticated the user
        router.get('/auth/facebook/callback',
            passport.authenticate('facebook'), (req, res) => this.facebookResponse(req, res)
        );

    }
开发者ID:Azizou,项目名称:Node-Data,代码行数:11,代码来源:auth-service.ts



注:本文中的passport.authenticate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript passport.deserializeUser函数代码示例发布时间:2022-05-25
下一篇:
TypeScript parsimmon.Parser类代码示例发布时间: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