From dd844dda217571dca428df9943953f215be17028 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Mon, 6 Feb 2017 16:38:07 +0100 Subject: [PATCH] Social url must be unique in socials links - Fix #306: --- www/plugins/es/js/controllers/user-controllers.js | 6 ++++++ www/plugins/es/js/services/user-services.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/www/plugins/es/js/controllers/user-controllers.js b/www/plugins/es/js/controllers/user-controllers.js index 92cb73f0c..90206521d 100644 --- a/www/plugins/es/js/controllers/user-controllers.js +++ b/www/plugins/es/js/controllers/user-controllers.js @@ -186,6 +186,12 @@ function ProfileController($scope, $rootScope, $timeout, $state, $focus, $transl }; var doFinishSave = function(formData) { + // Social url must be unique in socials links - Fix #306: + if (formData.socials && formData.socials.length) { + formData.socials = _.uniq(formData.socials, false, function(social) { + return social.url; + }); + } if (!$scope.existing) { return esUser.profile.add(formData) .then(function() { diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js index 9b096a434..d4fc8f302 100644 --- a/www/plugins/es/js/services/user-services.js +++ b/www/plugins/es/js/services/user-services.js @@ -389,6 +389,14 @@ angular.module('cesium.es.user.services', ['cesium.services', 'cesium.es.http.se data.name = profile.name; data.avatar = profile.avatar; data.profile = profile.source; + + // Social url must be unique in socials links - Workaround for issue #306: + if (data.profile && data.profile.socials && data.profile.socials.length) { + data.profile.socials = _.uniq(data.profile.socials, false, function(social) { + return social.url; + }); + } + } deferred.resolve(data); }), -- GitLab