auth-routes.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. const express = require('express');
  2. const router = express.Router();
  3. const passport = require('passport');
  4. const profile=require('./profile');
  5. router.get('/google', passport.authenticate('google', function(req,res){
  6. console.log(req);
  7. }));
  8. //callback route for google to redirect to
  9. router.get('/google/redirect',passport.authenticate('google',{ failureRedirect: '/login', session:false}),(req,res)=>{
  10. res.redirect('http://localhost:3000/?token='+req.user[0].token);
  11. });
  12. router.get('/facebook',passport.authenticate('facebook'),function(req,res){
  13. //console.log("request came");
  14. //console.log(req)
  15. });
  16. router.get('/facebook/redirect',passport.authenticate('facebook',{failureRedirect:'/',session:false}),(req,res) =>{
  17. //console.log(req.user[0].token)
  18. res.redirect('http://localhost:3000/'+req.user[0].token);
  19. });
  20. //passport.authenticate('/facebook/redirect', { successRedirect: 'http://localhost:3000/',
  21. // failureRedirect: 'http://localhost:3000' },(req,res)=>{
  22. // console.log("do i come here",req);
  23. // });
  24. module.exports = router;