mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
Added photo support
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user