auth using google

This commit is contained in:
2018-07-07 18:26:59 +03:00
parent aa6b0fb7af
commit bd957c89ef
17 changed files with 468 additions and 216 deletions

23
routes/google.js Normal file
View File

@@ -0,0 +1,23 @@
const express = require('express');
const passport = require('passport');
const router = express.Router();
const asyncHelper = require('../asyncHelper');
router.get(
'/google',
passport.authenticate('google', {
scope: ['https://www.googleapis.com/auth/plus.login'],
}),
);
router.get(
'/google/callback',
passport.authenticate('google', { session: false, failWithError: true }),
asyncHelper(async (req, res) => {
res.redirect(`/login?jwt=${req.user.generateJwt()}`);
}),
);
module.exports = router;