diff --git a/config/lib/seed.js b/config/lib/seed.js index d1ce86eaff..cc8f92db99 100644 --- a/config/lib/seed.js +++ b/config/lib/seed.js @@ -12,11 +12,11 @@ var seedOptions = {}; function removeUser (user) { return new Promise(function (resolve, reject) { var User = mongoose.model('User'); - User.find({username: user.username}).remove(function (err) { - if (err) { - reject(new Error('Failed to remove local ' + user.username)); - } - resolve(); + User.find({ username: user.username }).remove(function (err) { + if (err) { + reject(new Error('Failed to remove local ' + user.username)); + } + resolve(); }); }); } @@ -39,16 +39,16 @@ function saveUser (user) { function checkUserNotExists (user) { return new Promise(function (resolve, reject) { var User = mongoose.model('User'); - User.find({username: user.username}, function (err, users) { - if (err) { - reject(new Error('Failed to find local account ' + user.username)); - } + User.find({ username: user.username }, function (err, users) { + if (err) { + reject(new Error('Failed to find local account ' + user.username)); + } - if (users.length === 0) { - resolve(); - } else { - reject(new Error('Failed due to local account already exists: ' + user.username)); - } + if (users.length === 0) { + resolve(); + } else { + reject(new Error('Failed due to local account already exists: ' + user.username)); + } }); }); } diff --git a/modules/core/client/directives/show-errors.client.directives.js b/modules/core/client/directives/show-errors.client.directives.js index acfbea23d4..937df8ea9d 100644 --- a/modules/core/client/directives/show-errors.client.directives.js +++ b/modules/core/client/directives/show-errors.client.directives.js @@ -71,4 +71,4 @@ angular.module('core') return linkFn; } }; -}]); + }]); diff --git a/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js b/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js index 1b1e910e33..bfbd6c59e6 100644 --- a/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js +++ b/modules/core/tests/client/interceptors/auth.interceptor.client.tests.js @@ -4,9 +4,9 @@ describe('authInterceptor', function() { //Initialize global variables var authInterceptor, - $q, - $state, - httpProvider; + $q, + $state, + httpProvider; // Load the main application module beforeEach(module(ApplicationConfiguration.applicationModuleName)); @@ -25,11 +25,11 @@ })); it('Auth Interceptor should be object', function() { - expect( typeof authInterceptor).toEqual('object'); + expect(typeof authInterceptor).toEqual('object'); }); it('Auth Interceptor should contain responseError function', function() { - expect( typeof authInterceptor.responseError).toEqual('function'); + expect(typeof authInterceptor.responseError).toEqual('function'); }); it('httpProvider Interceptor should have authInterceptor', function() { @@ -38,19 +38,25 @@ describe('Forbidden Interceptor', function() { it('should redirect to forbidden route', function () { - var response = {status:403,config:{}}; - var promise = authInterceptor.responseError(response); - expect($q.reject).toHaveBeenCalled(); - expect($state.transitionTo).toHaveBeenCalledWith('forbidden'); + var response = { + status: 403, + config: {} + }; + var promise = authInterceptor.responseError(response); + expect($q.reject).toHaveBeenCalled(); + expect($state.transitionTo).toHaveBeenCalledWith('forbidden'); }); }); describe('Authorization Interceptor', function() { it('should redirect to signIn page for unauthorized access', function () { - var response = {status:401,config:{}}; - var promise = authInterceptor.responseError(response); - expect($q.reject).toHaveBeenCalled(); - expect($state.transitionTo).toHaveBeenCalledWith('authentication.signin'); + var response = { + status: 401, + config: {} + }; + var promise = authInterceptor.responseError(response); + expect($q.reject).toHaveBeenCalled(); + expect($state.transitionTo).toHaveBeenCalledWith('authentication.signin'); }); }); }); diff --git a/modules/core/tests/client/menus.client.service.tests.js b/modules/core/tests/client/menus.client.service.tests.js index 5bded019be..4482a5df06 100644 --- a/modules/core/tests/client/menus.client.service.tests.js +++ b/modules/core/tests/client/menus.client.service.tests.js @@ -328,7 +328,7 @@ Menus.addMenu(menuId); Menus.addMenuItem(menuId, menuItem1Options); Menus.addMenuItem(menuId, menuItem2Options); - Menus.addMenuItem(menuId, {state:'something.else'}); + Menus.addMenuItem(menuId, { state: 'something.else' }); Menus.addSubMenuItem(menuId, menuItem1Options.state, subItemOptions); menu = Menus.addSubMenuItem(menuId, menuItem1Options.state); menuItem1 = menu.items[0]; diff --git a/modules/core/tests/server/core.server.config.tests.js b/modules/core/tests/server/core.server.config.tests.js index b32302b13d..9635490475 100644 --- a/modules/core/tests/server/core.server.config.tests.js +++ b/modules/core/tests/server/core.server.config.tests.js @@ -70,7 +70,7 @@ describe('Configuration Tests:', function () { }); it('should not be an admin user to begin with', function(done) { - User.find({username: 'admin'}, function(err, users) { + User.find({ username: 'admin' }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(0); return done(); @@ -78,7 +78,7 @@ describe('Configuration Tests:', function () { }); it('should not be a "regular" user to begin with', function(done) { - User.find({username: 'user'}, function(err, users) { + User.find({ username: 'user' }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(0); return done(); @@ -92,7 +92,7 @@ describe('Configuration Tests:', function () { // Set node env ro production environment process.env.NODE_ENV = 'production'; - User.find({username: adminFromSeedConfig.username}, function(err, users) { + User.find({ username: adminFromSeedConfig.username }, function(err, users) { // There shouldn't be any errors should.not.exist(err); @@ -101,7 +101,7 @@ describe('Configuration Tests:', function () { seed .start({ logResults: false }) .then(function() { - User.find({username: adminFromSeedConfig.username}, function(err, users) { + User.find({ username: adminFromSeedConfig.username }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(1); @@ -127,7 +127,7 @@ describe('Configuration Tests:', function () { // Set node env ro production environment process.env.NODE_ENV = 'test'; - User.find({username: adminFromSeedConfig.username}, function(err, users) { + User.find({ username: adminFromSeedConfig.username }, function(err, users) { // There shouldn't be any errors should.not.exist(err); @@ -136,14 +136,14 @@ describe('Configuration Tests:', function () { seed .start({ logResults: false }) .then(function() { - User.find({username: adminFromSeedConfig.username}, function(err, users) { + User.find({ username: adminFromSeedConfig.username }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(1); var _admin = users.pop(); _admin.username.should.equal(adminFromSeedConfig.username); - User.find({username: userFromSeedConfig.username}, function(err, users) { + User.find({ username: userFromSeedConfig.username }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(1); @@ -215,7 +215,7 @@ describe('Configuration Tests:', function () { // Set node env ro production environment process.env.NODE_ENV = 'production'; - User.find({username: admin1.username}, function(err, users) { + User.find({ username: admin1.username }, function(err, users) { // There shouldn't be any errors should.not.exist(err); @@ -224,7 +224,7 @@ describe('Configuration Tests:', function () { seed .start({ logResults: false, seedAdmin: admin1 }) .then(function() { - User.find({username: admin1.username}, function(err, users) { + User.find({ username: admin1.username }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(1); @@ -250,7 +250,7 @@ describe('Configuration Tests:', function () { // Set node env ro production environment process.env.NODE_ENV = 'test'; - User.find({username: admin1.username}, function(err, users) { + User.find({ username: admin1.username }, function(err, users) { // There shouldn't be any errors should.not.exist(err); @@ -259,14 +259,14 @@ describe('Configuration Tests:', function () { seed .start({ logResults: false, seedAdmin: admin1, seedUser: user1 }) .then(function() { - User.find({username: admin1.username}, function(err, users) { + User.find({ username: admin1.username }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(1); var _admin = users.pop(); _admin.username.should.equal(admin1.username); - User.find({username: user1.username}, function(err, users) { + User.find({ username: user1.username }, function(err, users) { should.not.exist(err); users.should.be.instanceof(Array).and.have.lengthOf(1); diff --git a/modules/users/client/directives/password-validator.client.directive.js b/modules/users/client/directives/password-validator.client.directive.js index a0ef1eaa95..25565e235e 100644 --- a/modules/users/client/directives/password-validator.client.directive.js +++ b/modules/users/client/directives/password-validator.client.directive.js @@ -39,4 +39,4 @@ angular.module('users') }); } }; -}]); + }]); diff --git a/modules/users/client/directives/password-verify.client.directive.js b/modules/users/client/directives/password-verify.client.directive.js index e31565dbde..9f219742ae 100644 --- a/modules/users/client/directives/password-verify.client.directive.js +++ b/modules/users/client/directives/password-verify.client.directive.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('users') - .directive('passwordVerify', function() { + .directive('passwordVerify', [function() { return { require: 'ngModel', scope: { @@ -28,6 +28,6 @@ angular.module('users') }); } }); - } + } }; -}); + }]); diff --git a/modules/users/server/config/strategies/facebook.js b/modules/users/server/config/strategies/facebook.js index 2f2180b8d7..8c525350e1 100644 --- a/modules/users/server/config/strategies/facebook.js +++ b/modules/users/server/config/strategies/facebook.js @@ -10,45 +10,44 @@ var passport = require('passport'), module.exports = function (config) { // Use facebook strategy passport.use(new FacebookStrategy({ - clientID: config.facebook.clientID, - clientSecret: config.facebook.clientSecret, - callbackURL: config.facebook.callbackURL, - profileFields: ['id', 'name', 'displayName', 'emails', 'photos'], - passReqToCallback: true - }, - function (req, accessToken, refreshToken, profile, done) { - // Set the provider data and include tokens - var providerData = profile._json; - providerData.accessToken = accessToken; - providerData.refreshToken = refreshToken; + clientID: config.facebook.clientID, + clientSecret: config.facebook.clientSecret, + callbackURL: config.facebook.callbackURL, + profileFields: ['id', 'name', 'displayName', 'emails', 'photos'], + passReqToCallback: true + }, + function (req, accessToken, refreshToken, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.accessToken = accessToken; + providerData.refreshToken = refreshToken; - // Create the user OAuth profile - var providerUserProfile = { - firstName: profile.name.givenName, - lastName: profile.name.familyName, - displayName: profile.displayName, - email: profile.emails ? profile.emails[0].value : undefined, - username: profile.username || generateUsername(profile), - profileImageURL: (profile.id) ? '//graph.facebook.com/' + profile.id + '/picture?type=large' : undefined, - provider: 'facebook', - providerIdentifierField: 'id', - providerData: providerData - }; + // Create the user OAuth profile + var providerUserProfile = { + firstName: profile.name.givenName, + lastName: profile.name.familyName, + displayName: profile.displayName, + email: profile.emails ? profile.emails[0].value : undefined, + username: profile.username || generateUsername(profile), + profileImageURL: (profile.id) ? '//graph.facebook.com/' + profile.id + '/picture?type=large' : undefined, + provider: 'facebook', + providerIdentifierField: 'id', + providerData: providerData + }; - // Save the user OAuth profile - users.saveOAuthUserProfile(req, providerUserProfile, done); + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); - function generateUsername(profile) { - var username = ''; + function generateUsername(profile) { + var username = ''; - if (profile.emails) { - username = profile.emails[0].value.split('@')[0]; - } else if (profile.name) { - username = profile.name.givenName[0] + profile.name.familyName; - } - - return username.toLowerCase() || undefined; + if (profile.emails) { + username = profile.emails[0].value.split('@')[0]; + } else if (profile.name) { + username = profile.name.givenName[0] + profile.name.familyName; } + + return username.toLowerCase() || undefined; } - )); + })); }; diff --git a/modules/users/server/config/strategies/github.js b/modules/users/server/config/strategies/github.js index 6e996e6306..643b7418e3 100644 --- a/modules/users/server/config/strategies/github.js +++ b/modules/users/server/config/strategies/github.js @@ -10,39 +10,38 @@ var passport = require('passport'), module.exports = function (config) { // Use github strategy passport.use(new GithubStrategy({ - clientID: config.github.clientID, - clientSecret: config.github.clientSecret, - callbackURL: config.github.callbackURL, - passReqToCallback: true - }, - function (req, accessToken, refreshToken, profile, done) { - // Set the provider data and include tokens - var providerData = profile._json; - providerData.accessToken = accessToken; - providerData.refreshToken = refreshToken; + clientID: config.github.clientID, + clientSecret: config.github.clientSecret, + callbackURL: config.github.callbackURL, + passReqToCallback: true + }, + function (req, accessToken, refreshToken, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.accessToken = accessToken; + providerData.refreshToken = refreshToken; - // Create the user OAuth profile - var displayName = profile.displayName ? profile.displayName.trim() : profile.username.trim(); - var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName - var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName; - var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : ''; + // Create the user OAuth profile + var displayName = profile.displayName ? profile.displayName.trim() : profile.username.trim(); + var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName + var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName; + var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : ''; - var providerUserProfile = { - firstName: firstName, - lastName: lastName, - displayName: displayName, - email: profile.emails[0].value, - username: profile.username, - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - profileImageURL: (providerData.avatar_url) ? providerData.avatar_url : undefined, - // jscs:enable - provider: 'github', - providerIdentifierField: 'id', - providerData: providerData - }; + var providerUserProfile = { + firstName: firstName, + lastName: lastName, + displayName: displayName, + email: profile.emails[0].value, + username: profile.username, + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + profileImageURL: (providerData.avatar_url) ? providerData.avatar_url : undefined, + // jscs:enable + provider: 'github', + providerIdentifierField: 'id', + providerData: providerData + }; - // Save the user OAuth profile - users.saveOAuthUserProfile(req, providerUserProfile, done); - } - )); + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + })); }; diff --git a/modules/users/server/config/strategies/google.js b/modules/users/server/config/strategies/google.js index b2e023bd28..68c4b8466b 100644 --- a/modules/users/server/config/strategies/google.js +++ b/modules/users/server/config/strategies/google.js @@ -10,32 +10,31 @@ var passport = require('passport'), module.exports = function (config) { // Use google strategy passport.use(new GoogleStrategy({ - clientID: config.google.clientID, - clientSecret: config.google.clientSecret, - callbackURL: config.google.callbackURL, - passReqToCallback: true - }, - function (req, accessToken, refreshToken, profile, done) { - // Set the provider data and include tokens - var providerData = profile._json; - providerData.accessToken = accessToken; - providerData.refreshToken = refreshToken; + clientID: config.google.clientID, + clientSecret: config.google.clientSecret, + callbackURL: config.google.callbackURL, + passReqToCallback: true + }, + function (req, accessToken, refreshToken, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.accessToken = accessToken; + providerData.refreshToken = refreshToken; - // Create the user OAuth profile - var providerUserProfile = { - firstName: profile.name.givenName, - lastName: profile.name.familyName, - displayName: profile.displayName, - email: profile.emails[0].value, - username: profile.username, - profileImageURL: (providerData.picture) ? providerData.picture : undefined, - provider: 'google', - providerIdentifierField: 'id', - providerData: providerData - }; + // Create the user OAuth profile + var providerUserProfile = { + firstName: profile.name.givenName, + lastName: profile.name.familyName, + displayName: profile.displayName, + email: profile.emails[0].value, + username: profile.username, + profileImageURL: (providerData.picture) ? providerData.picture : undefined, + provider: 'google', + providerIdentifierField: 'id', + providerData: providerData + }; - // Save the user OAuth profile - users.saveOAuthUserProfile(req, providerUserProfile, done); - } - )); + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + })); }; diff --git a/modules/users/server/config/strategies/linkedin.js b/modules/users/server/config/strategies/linkedin.js index d6ae408d07..47b4e477c8 100644 --- a/modules/users/server/config/strategies/linkedin.js +++ b/modules/users/server/config/strategies/linkedin.js @@ -10,33 +10,32 @@ var passport = require('passport'), module.exports = function (config) { // Use linkedin strategy passport.use(new LinkedInStrategy({ - consumerKey: config.linkedin.clientID, - consumerSecret: config.linkedin.clientSecret, - callbackURL: config.linkedin.callbackURL, - passReqToCallback: true, - profileFields: ['id', 'first-name', 'last-name', 'email-address', 'picture-url'] - }, - function (req, accessToken, refreshToken, profile, done) { - // Set the provider data and include tokens - var providerData = profile._json; - providerData.accessToken = accessToken; - providerData.refreshToken = refreshToken; + consumerKey: config.linkedin.clientID, + consumerSecret: config.linkedin.clientSecret, + callbackURL: config.linkedin.callbackURL, + passReqToCallback: true, + profileFields: ['id', 'first-name', 'last-name', 'email-address', 'picture-url'] + }, + function (req, accessToken, refreshToken, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.accessToken = accessToken; + providerData.refreshToken = refreshToken; - // Create the user OAuth profile - var providerUserProfile = { - firstName: profile.name.givenName, - lastName: profile.name.familyName, - displayName: profile.displayName, - email: profile.emails[0].value, - username: profile.username, - profileImageURL: (providerData.pictureUrl) ? providerData.pictureUrl : undefined, - provider: 'linkedin', - providerIdentifierField: 'id', - providerData: providerData - }; + // Create the user OAuth profile + var providerUserProfile = { + firstName: profile.name.givenName, + lastName: profile.name.familyName, + displayName: profile.displayName, + email: profile.emails[0].value, + username: profile.username, + profileImageURL: (providerData.pictureUrl) ? providerData.pictureUrl : undefined, + provider: 'linkedin', + providerIdentifierField: 'id', + providerData: providerData + }; - // Save the user OAuth profile - users.saveOAuthUserProfile(req, providerUserProfile, done); - } - )); + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + })); }; diff --git a/modules/users/server/config/strategies/local.js b/modules/users/server/config/strategies/local.js index a72510f496..97435c4aac 100644 --- a/modules/users/server/config/strategies/local.js +++ b/modules/users/server/config/strategies/local.js @@ -10,24 +10,23 @@ var passport = require('passport'), module.exports = function () { // Use local strategy passport.use(new LocalStrategy({ - usernameField: 'username', - passwordField: 'password' - }, - function (username, password, done) { - User.findOne({ - username: username.toLowerCase() - }, function (err, user) { - if (err) { - return done(err); - } - if (!user || !user.authenticate(password)) { - return done(null, false, { - message: 'Invalid username or password' - }); - } + usernameField: 'username', + passwordField: 'password' + }, + function (username, password, done) { + User.findOne({ + username: username.toLowerCase() + }, function (err, user) { + if (err) { + return done(err); + } + if (!user || !user.authenticate(password)) { + return done(null, false, { + message: 'Invalid username or password' + }); + } - return done(null, user); - }); - } - )); + return done(null, user); + }); + })); }; diff --git a/modules/users/server/config/strategies/paypal.js b/modules/users/server/config/strategies/paypal.js index c0d97302ee..6546fa18ce 100644 --- a/modules/users/server/config/strategies/paypal.js +++ b/modules/users/server/config/strategies/paypal.js @@ -9,34 +9,33 @@ var passport = require('passport'), module.exports = function (config) { passport.use(new PayPalStrategy({ - clientID: config.paypal.clientID, - clientSecret: config.paypal.clientSecret, - callbackURL: config.paypal.callbackURL, - scope: 'openid profile email', - sandbox: config.paypal.sandbox, - passReqToCallback: true + clientID: config.paypal.clientID, + clientSecret: config.paypal.clientSecret, + callbackURL: config.paypal.callbackURL, + scope: 'openid profile email', + sandbox: config.paypal.sandbox, + passReqToCallback: true - }, - function (req, accessToken, refreshToken, profile, done) { - // Set the provider data and include tokens - var providerData = profile._json; - providerData.accessToken = accessToken; - providerData.refreshToken = refreshToken; + }, + function (req, accessToken, refreshToken, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.accessToken = accessToken; + providerData.refreshToken = refreshToken; - // Create the user OAuth profile - var providerUserProfile = { - firstName: profile.name.givenName, - lastName: profile.name.familyName, - displayName: profile.displayName, - email: profile._json.email, - username: profile.username, - provider: 'paypal', - providerIdentifierField: 'user_id', - providerData: providerData - }; + // Create the user OAuth profile + var providerUserProfile = { + firstName: profile.name.givenName, + lastName: profile.name.familyName, + displayName: profile.displayName, + email: profile._json.email, + username: profile.username, + provider: 'paypal', + providerIdentifierField: 'user_id', + providerData: providerData + }; - // Save the user OAuth profile - users.saveOAuthUserProfile(req, providerUserProfile, done); - } - )); + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + })); }; diff --git a/modules/users/server/config/strategies/twitter.js b/modules/users/server/config/strategies/twitter.js index 2f1d5abe40..919d105451 100644 --- a/modules/users/server/config/strategies/twitter.js +++ b/modules/users/server/config/strategies/twitter.js @@ -10,36 +10,35 @@ var passport = require('passport'), module.exports = function (config) { // Use twitter strategy passport.use(new TwitterStrategy({ - consumerKey: config.twitter.clientID, - consumerSecret: config.twitter.clientSecret, - callbackURL: config.twitter.callbackURL, - passReqToCallback: true - }, - function (req, token, tokenSecret, profile, done) { - // Set the provider data and include tokens - var providerData = profile._json; - providerData.token = token; - providerData.tokenSecret = tokenSecret; + consumerKey: config.twitter.clientID, + consumerSecret: config.twitter.clientSecret, + callbackURL: config.twitter.callbackURL, + passReqToCallback: true + }, + function (req, token, tokenSecret, profile, done) { + // Set the provider data and include tokens + var providerData = profile._json; + providerData.token = token; + providerData.tokenSecret = tokenSecret; - // Create the user OAuth profile - var displayName = profile.displayName.trim(); - var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName - var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName; - var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : ''; + // Create the user OAuth profile + var displayName = profile.displayName.trim(); + var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName + var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName; + var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : ''; - var providerUserProfile = { - firstName: firstName, - lastName: lastName, - displayName: displayName, - username: profile.username, - profileImageURL: profile.photos[0].value.replace('normal', 'bigger'), - provider: 'twitter', - providerIdentifierField: 'id_str', - providerData: providerData - }; + var providerUserProfile = { + firstName: firstName, + lastName: lastName, + displayName: displayName, + username: profile.username, + profileImageURL: profile.photos[0].value.replace('normal', 'bigger'), + provider: 'twitter', + providerIdentifierField: 'id_str', + providerData: providerData + }; - // Save the user OAuth profile - users.saveOAuthUserProfile(req, providerUserProfile, done); - } - )); + // Save the user OAuth profile + users.saveOAuthUserProfile(req, providerUserProfile, done); + })); }; diff --git a/modules/users/tests/server/user.server.routes.tests.js b/modules/users/tests/server/user.server.routes.tests.js index fd7ff378f0..f84802159c 100644 --- a/modules/users/tests/server/user.server.routes.tests.js +++ b/modules/users/tests/server/user.server.routes.tests.js @@ -357,7 +357,7 @@ describe('User CRUD tests', function () { return done(err); } - User.findOne({username: user.username.toLowerCase()}, function(err, userRes) { + User.findOne({ username: user.username.toLowerCase() }, function(err, userRes) { userRes.resetPasswordToken.should.not.be.empty(); should.exist(userRes.resetPasswordExpires); res.body.message.should.be.equal('Failure sending email'); @@ -383,7 +383,7 @@ describe('User CRUD tests', function () { return done(err); } - User.findOne({username: user.username.toLowerCase()}, function(err, userRes) { + User.findOne({ username: user.username.toLowerCase() }, function(err, userRes) { userRes.resetPasswordToken.should.not.be.empty(); should.exist(userRes.resetPasswordExpires); @@ -398,9 +398,9 @@ describe('User CRUD tests', function () { res.headers.location.should.be.equal('/password/reset/' + userRes.resetPasswordToken); return done(); + }); }); }); - }); }); }); @@ -432,8 +432,8 @@ describe('User CRUD tests', function () { res.headers.location.should.be.equal('/password/reset/invalid'); return done(); + }); }); - }); }); });