Skip to content

Instantly share code, notes, and snippets.

@MuhammadHasham23
Created January 26, 2018 21:07
Show Gist options
  • Save MuhammadHasham23/9be6185fe80dbe18c77c1b4b9758a5bc to your computer and use it in GitHub Desktop.
Save MuhammadHasham23/9be6185fe80dbe18c77c1b4b9758a5bc to your computer and use it in GitHub Desktop.
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" });
};
//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