Created
January 26, 2018 21:07
-
-
Save MuhammadHasham23/9be6185fe80dbe18c77c1b4b9758a5bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
export const addTodo = item => async dispatch => { | |
const res = await axios.post("http://localhost:5000/addTodo", item); | |
dispatch({ type: "ADD_TODO", payload: "res" }); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Basic Routes | |
const passport = require("passport"); | |
const GoogleStrategy = require("passport-google-oauth20").Strategy; | |
const mongoose = require("mongoose"); | |
const UserSchema = mongoose.model("UserSchema"); | |
module.exports = app => { | |
app.get("/", (req, res) => { | |
res.send("Hello World"); | |
}); | |
app.post("/addTodo", (req, res) => { | |
console.log(req.user); | |
// UserSchema.findOne({ _id: req.session.passport.user }, function(err, res) { | |
// res.todos.push({ name: req.body.todo, isCompleted: false }); | |
// res.save((err, value) => {}); | |
// }); | |
res.send("Add todo"); | |
}); | |
}; | |
//Auth Roiutes | |
const passport = require("passport"); | |
const GoogleStrategy = require("passport-google-oauth20").Strategy; | |
module.exports = app => { | |
app.get( | |
"/auth/google", | |
passport.authenticate("google", { scope: ["profile", "email"] }) | |
); | |
app.get( | |
"/auth/google/callback", | |
passport.authenticate("google", { failureRedirect: "/login" }), | |
function(req, res) { | |
res.redirect("/"); | |
} | |
); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment