From c95bd7d1cb0c6e651f82b2b4cfa4e937d4dcf154 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Thu, 7 Jul 2016 01:24:23 +0300 Subject: [PATCH] fix(core): fix ESLint console warnings, Twitter redirect, and and scope usage (#1388) * Use validator.js instead of regexp for validations in User Schema. * Disables "Unexpected console statement no-console" warnings * Fixes redirection to wrong URL after login with social networks. * Use ViewModel vm instead of $scope in manage social accounts controller. * preserving the option to redirect to a specific URL as done in saveOAuthUserProfile() (thanks to @OneOfTheWorld for pointing out) --- .eslintrc.js | 1 + .../settings/manage-social-accounts.client.controller.js | 2 +- .../users/users.authentication.server.controller.js | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f03e9c512d..e61935fb47 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,7 @@ module.exports = { 'new-cap': [2, { newIsCapExceptions: ['acl.memoryBackend', 'acl'] }], 'no-bitwise': 0, 'no-caller': 2, + 'no-console': 0, 'no-else-return': 0, 'no-empty-class': 0, 'no-multi-spaces': 2, diff --git a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js index f6411a43af..03f6548e96 100644 --- a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js +++ b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js @@ -17,7 +17,7 @@ // Check if there are additional accounts function hasConnectedAdditionalSocialAccounts() { - return ($scope.user.additionalProvidersData && Object.keys($scope.user.additionalProvidersData).length); + return (vm.user.additionalProvidersData && Object.keys(vm.user.additionalProvidersData).length); } // Check if provider is already in use with current user diff --git a/modules/users/server/controllers/users/users.authentication.server.controller.js b/modules/users/server/controllers/users/users.authentication.server.controller.js index c88497f0b8..56a962e8e9 100644 --- a/modules/users/server/controllers/users/users.authentication.server.controller.js +++ b/modules/users/server/controllers/users/users.authentication.server.controller.js @@ -104,7 +104,7 @@ exports.oauthCallback = function (strategy) { var sessionRedirectURL = req.session.redirect_to; delete req.session.redirect_to; - passport.authenticate(strategy, function (err, user, redirectURL) { + passport.authenticate(strategy, function (err, user, info) { if (err) { return res.redirect('/authentication/signin?err=' + encodeURIComponent(errorHandler.getErrorMessage(err))); } @@ -116,7 +116,7 @@ exports.oauthCallback = function (strategy) { return res.redirect('/authentication/signin'); } - return res.redirect(redirectURL || sessionRedirectURL || '/'); + return res.redirect(info || sessionRedirectURL || '/'); }); })(req, res, next); };