This file contains hidden or 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
const passport = require("passport"); | |
var GitHubStrategy = require("passport-github2").Strategy; | |
const User = require("../models/user-model"); | |
// Passport takes that user id and stores it internally on | |
// req.session.passport which is passport’s internal | |
// mechanism to keep track of things. | |
passport.serializeUser((user, done) => { | |
done(null, user.id); | |
}); |
This file contains hidden or 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
const mongoose = require("mongoose"); | |
const Schema = mongoose.Schema; | |
const userSchema = new Schema({ | |
username: String, | |
name: String, | |
githubId: String, | |
image: String | |
}); |
This file contains hidden or 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
var cookieSession = require('cookie-session'); | |
var passport = require('passport'); | |
const passportSetup = require('./config/passport-setup'); | |
var authRouter = require('./routes/auth-routes'); | |
app.use('/auth', authRouter); | |
var mongoose = require("mongoose"); |
This file contains hidden or 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
var express = require('express'); | |
var router = express.Router(); | |
var passport = require('passport'); | |
// To return the user data to the client | |
router.get("/check", (req, res) => { | |
console.log("user - " + req.user); | |
console.log(req.session.passport); | |
if (req.user === undefined) { | |
res.json({}); |
NewerOlder