LinkedIn generator indentation fixes
This commit is contained in:
120
generator.js
120
generator.js
@ -640,97 +640,97 @@ inquirer.prompt({
|
|||||||
var linkedinStrategyRequire = "var LinkedInStrategy = require('passport-linkedin-oauth2').Strategy;";
|
var linkedinStrategyRequire = "var LinkedInStrategy = require('passport-linkedin-oauth2').Strategy;";
|
||||||
var linkedinStrategy = M(function() {
|
var linkedinStrategy = M(function() {
|
||||||
/***
|
/***
|
||||||
// Sign in with LinkedIn.
|
// Sign in with LinkedIn.
|
||||||
|
|
||||||
passport.use(new LinkedInStrategy(secrets.linkedin, function(req, accessToken, refreshToken, profile, done) {
|
passport.use(new LinkedInStrategy(secrets.linkedin, function(req, accessToken, refreshToken, profile, done) {
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
User.findOne({ $or: [
|
User.findOne({ $or: [
|
||||||
{ linkedin: profile.id },
|
{ linkedin: profile.id },
|
||||||
{ email: profile._json.emailAddress }
|
{ email: profile._json.emailAddress }
|
||||||
] }, function(err, existingUser) {
|
] }, function(err, existingUser) {
|
||||||
if (existingUser) {
|
if (existingUser) {
|
||||||
req.flash('errors', { msg: 'There is already a LinkedIn account that belongs to you. Sign in with that account or delete it, then link it with your current account.' });
|
req.flash('errors', { msg: 'There is already a LinkedIn account that belongs to you. Sign in with that account or delete it, then link it with your current account.' });
|
||||||
|
done(err);
|
||||||
|
} else {
|
||||||
|
User.findById(req.user.id, function(err, user) {
|
||||||
|
user.linkedin = profile.id;
|
||||||
|
user.tokens.push({ kind: 'linkedin', accessToken: accessToken });
|
||||||
|
user.profile.name = user.profile.name || profile.displayName;
|
||||||
|
user.profile.location = user.profile.location || profile._json.location.name;
|
||||||
|
user.profile.picture = user.profile.picture || profile._json.pictureUrl;
|
||||||
|
user.profile.website = user.profile.website || profile._json.publicProfileUrl;
|
||||||
|
user.save(function(err) {
|
||||||
|
req.flash('info', { msg: 'LinkedIn account has been linked.' });
|
||||||
|
done(err, user);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
User.findOne({ linkedin: profile.id }, function(err, existingUser) {
|
||||||
|
if (existingUser) return done(null, existingUser);
|
||||||
|
User.findOne({ email: profile._json.emailAddress }, function(err, existingEmailUser) {
|
||||||
|
if (existingEmailUser) {
|
||||||
|
req.flash('errors', { msg: 'There is already an account using this email address. Sign in to that account and link it with LinkedIn manually from Account Settings.' });
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
User.findById(req.user.id, function(err, user) {
|
var user = new User();
|
||||||
user.linkedin = profile.id;
|
user.linkedin = profile.id;
|
||||||
user.tokens.push({ kind: 'linkedin', accessToken: accessToken });
|
user.tokens.push({ kind: 'linkedin', accessToken: accessToken });
|
||||||
user.profile.name = user.profile.name || profile.displayName;
|
user.email = profile._json.emailAddress;
|
||||||
user.profile.location = user.profile.location || profile._json.location.name;
|
user.profile.name = profile.displayName;
|
||||||
user.profile.picture = user.profile.picture || profile._json.pictureUrl;
|
user.profile.location = profile._json.location.name;
|
||||||
user.profile.website = user.profile.website || profile._json.publicProfileUrl;
|
user.profile.picture = profile._json.pictureUrl;
|
||||||
user.save(function(err) {
|
user.profile.website = profile._json.publicProfileUrl;
|
||||||
req.flash('info', { msg: 'LinkedIn account has been linked.' });
|
user.save(function(err) {
|
||||||
done(err, user);
|
done(err, user);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
User.findOne({ linkedin: profile.id }, function(err, existingUser) {
|
}
|
||||||
if (existingUser) return done(null, existingUser);
|
}));
|
||||||
User.findOne({ email: profile._json.emailAddress }, function(err, existingEmailUser) {
|
***/
|
||||||
if (existingEmailUser) {
|
|
||||||
req.flash('errors', { msg: 'There is already an account using this email address. Sign in to that account and link it with LinkedIn manually from Account Settings.' });
|
|
||||||
done(err);
|
|
||||||
} else {
|
|
||||||
var user = new User();
|
|
||||||
user.linkedin = profile.id;
|
|
||||||
user.tokens.push({ kind: 'linkedin', accessToken: accessToken });
|
|
||||||
user.email = profile._json.emailAddress;
|
|
||||||
user.profile.name = profile.displayName;
|
|
||||||
user.profile.location = profile._json.location.name;
|
|
||||||
user.profile.picture = profile._json.pictureUrl;
|
|
||||||
user.profile.website = profile._json.publicProfileUrl;
|
|
||||||
user.save(function(err) {
|
|
||||||
done(err, user);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
***/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var linkedinButton = M(function() {
|
var linkedinButton = M(function() {
|
||||||
/***
|
/***
|
||||||
a.btn.btn-block.btn-linkedin.btn-social(href='/auth/linkedin')
|
a.btn.btn-block.btn-linkedin.btn-social(href='/auth/linkedin')
|
||||||
i.fa.fa-linkedin
|
i.fa.fa-linkedin
|
||||||
| Sign in with LinkedIn
|
| Sign in with LinkedIn
|
||||||
***/
|
***/
|
||||||
});
|
});
|
||||||
var linkedinLinkUnlink = M(function() {
|
var linkedinLinkUnlink = M(function() {
|
||||||
/***
|
/***
|
||||||
|
|
||||||
if user.linkedin
|
if user.linkedin
|
||||||
p: a.text-danger(href='/account/unlink/linkedin') Unlink your LinkedIn account
|
p: a.text-danger(href='/account/unlink/linkedin') Unlink your LinkedIn account
|
||||||
else
|
else
|
||||||
p: a(href='/auth/linkedin') Link your LinkedIn account
|
p: a(href='/auth/linkedin') Link your LinkedIn account
|
||||||
***/
|
***/
|
||||||
});
|
});
|
||||||
var linkedinModel = ' linkedin: String,';
|
var linkedinModel = ' linkedin: String,';
|
||||||
|
|
||||||
if (_.contains(answer.auth, 'LinkedIn')) {
|
if (_.contains(answer.auth, 'LinkedIn')) {
|
||||||
if (passportConfig.indexOf(linkedinStrategyRequire) < 0) {
|
if (passportConfig.indexOf(linkedinStrategyRequire) < 0) {
|
||||||
|
|
||||||
// config/passport.js (+)
|
// Add LinkedIn to passport.js
|
||||||
index = passportConfig.indexOf("var passport = require('passport');");
|
index = passportConfig.indexOf("var passport = require('passport');");
|
||||||
passportConfig.splice(index + 1, 0, linkedinStrategyRequire);
|
passportConfig.splice(index + 1, 0, linkedinStrategyRequire);
|
||||||
index = passportConfig.indexOf('passport.deserializeUser(function(id, done) {');
|
index = passportConfig.indexOf('passport.deserializeUser(function(id, done) {');
|
||||||
passportConfig.splice(index + 6, 0, linkedinStrategy);
|
passportConfig.splice(index + 6, 0, linkedinStrategy);
|
||||||
fs.writeFileSync(passportConfigFile, passportConfig.join('\n'));
|
fs.writeFileSync(passportConfigFile, passportConfig.join('\n'));
|
||||||
|
|
||||||
// views/account/login.jade (+)
|
// Add LinkedIn to login.jade
|
||||||
loginTemplate.push(linkedinButton);
|
loginTemplate.push(linkedinButton);
|
||||||
fs.writeFileSync(loginTemplateFile, loginTemplate.join('\n'));
|
fs.writeFileSync(loginTemplateFile, loginTemplate.join('\n'));
|
||||||
|
|
||||||
// views/account/profile.jade (+)
|
// Add LinkedIn to profile.jade
|
||||||
index = profileTemplate.indexOf(' h3 Linked Accounts');
|
index = profileTemplate.indexOf(' h3 Linked Accounts');
|
||||||
profileTemplate.splice(index + 1, 0, linkedinLinkUnlink);
|
profileTemplate.splice(index + 1, 0, linkedinLinkUnlink);
|
||||||
fs.writeFileSync(profileTemplateFile, profileTemplate.join('\n'));
|
fs.writeFileSync(profileTemplateFile, profileTemplate.join('\n'));
|
||||||
|
|
||||||
// models/User.js (+)
|
// Add LinkedIn to models/User.js
|
||||||
index = userModel.indexOf(' tokens: Array,');
|
index = userModel.indexOf(' tokens: Array,');
|
||||||
userModel.splice(index - 1, 0, linkedinModel);
|
userModel.splice(index - 1, 0, linkedinModel);
|
||||||
fs.writeFileSync(userModelFile, userModel.join('\n'));
|
fs.writeFileSync(userModelFile, userModel.join('\n'));
|
||||||
@ -744,7 +744,7 @@ inquirer.prompt({
|
|||||||
// Check if we have LinkedIn authentication to begin with.
|
// Check if we have LinkedIn authentication to begin with.
|
||||||
if (passportConfig.indexOf(linkedinStrategyRequire) < 0) return;
|
if (passportConfig.indexOf(linkedinStrategyRequire) < 0) return;
|
||||||
|
|
||||||
// Removed LinkedIn from config/passport.js
|
// Removed LinkedIn from passport.js
|
||||||
index = passportConfig.indexOf(linkedinStrategyRequire);
|
index = passportConfig.indexOf(linkedinStrategyRequire);
|
||||||
passportConfig.splice(index, 1);
|
passportConfig.splice(index, 1);
|
||||||
index = passportConfig.indexOf('// Sign in with LinkedIn.');
|
index = passportConfig.indexOf('// Sign in with LinkedIn.');
|
||||||
@ -890,7 +890,7 @@ inquirer.prompt({
|
|||||||
|
|
||||||
console.log('✗ Local authentication has been removed.'.error);
|
console.log('✗ Local authentication has been removed.'.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Instagram Authentication //
|
// Instagram Authentication //
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
Reference in New Issue
Block a user