Added photo support

This commit is contained in:
Wyatt Johnson
2016-11-11 14:59:27 -07:00
parent 68433ec973
commit 80e12d2e30
3 changed files with 6 additions and 3 deletions
+2
View File
@@ -12,6 +12,7 @@ const UserSchema = new mongoose.Schema({
required: true
},
displayName: String,
photo: String,
disabled: Boolean,
password: String,
profiles: [{
@@ -139,6 +140,7 @@ UserSchema.statics.findOrCreateExternalUser = function(profile) {
user = new User({
displayName: profile.displayName,
roles: [],
photo: Array.isArray(profile.photos) && profile.photos.length > 0 ? profile.photos[0].value : null,
profiles: [
{
id: profile.id,
+2 -1
View File
@@ -65,7 +65,8 @@ if (process.env.TALK_FACEBOOK_APP_ID && process.env.TALK_FACEBOOK_APP_SECRET &&
passport.use(new FacebookStrategy({
clientID: process.env.TALK_FACEBOOK_APP_ID,
clientSecret: process.env.TALK_FACEBOOK_APP_SECRET,
callbackURL: `${process.env.TALK_ROOT_URL}/api/v1/auth/facebook/callback`
callbackURL: `${process.env.TALK_ROOT_URL}/api/v1/auth/facebook/callback`,
profileFields: ['id', 'displayName', 'picture.type(large)']
}, (accessToken, refreshToken, profile, done) => {
User
.findOrCreateExternalUser(profile)
+2 -2
View File
@@ -14,7 +14,7 @@ router.get('/', authorization.needed(), (req, res) => {
/**
* This destroys the session of a user, if they have one.
*/
router.delete('/', authorization.needed(), (req, res) => {
router.delete('/', (req, res) => {
req.session.destroy(() => {
res.status(204).end();
});
@@ -79,7 +79,7 @@ router.post('/local', (req, res, next) => {
* Facebook auth endpoint, this will redirect the user immediatly to facebook
* for authorization.
*/
router.get('/facebook', passport.authenticate('facebook', {display: 'popup'}));
router.get('/facebook', passport.authenticate('facebook', {display: 'popup', authType: 'rerequest', scope: ['public_profile']}));
/**
* Facebook callback endpoint, this will send the user a html page designed to