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


TypeScript passport.authenticate函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。