mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 23:57:49 +01:00
auth using google
This commit is contained in:
23
routes/google.js
Normal file
23
routes/google.js
Normal 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;
|
||||
Reference in New Issue
Block a user