diff --git a/src/frontend/js/modules/avatar/avatar-url.service.js b/src/frontend/js/modules/avatar/avatar-url.service.js index 903a27a9..cd4a7b53 100644 --- a/src/frontend/js/modules/avatar/avatar-url.service.js +++ b/src/frontend/js/modules/avatar/avatar-url.service.js @@ -4,7 +4,7 @@ angular.module('esn.avatar') .factory('esnAvatarUrlService', esnAvatarUrlService); - function esnAvatarUrlService(urlUtils) { + function esnAvatarUrlService($log, urlUtils) { return { generateUrl: generateUrl, generateForCurrentUser: generateForCurrentUser, @@ -17,6 +17,8 @@ } function generateForCurrentUser(noCache) { + $log.warn('DEPRECATION: The esnAvatarUrlService.generateForCurrentUser should not be used anymore, as it is not compatible with OIDC.'); + return applyTimestamp('/api/user/profile/avatar', noCache); } diff --git a/src/frontend/js/modules/header/profile-menu/profile-menu-.component.spec.js b/src/frontend/js/modules/header/profile-menu/profile-menu-.component.spec.js index f56748e9..517d1c1c 100644 --- a/src/frontend/js/modules/header/profile-menu/profile-menu-.component.spec.js +++ b/src/frontend/js/modules/header/profile-menu/profile-menu-.component.spec.js @@ -52,7 +52,12 @@ describe('The profileMenu component', function() { }); it('should retrieve a coherent avatarUrl', function() { - var regexpAvatarUrl = /^\/api\/user\/profile\/avatar\?cb=\d+$/; + var regexpAvatarUrl = /^\/api\/users\/123\/profile\/avatar\?cb=\d+$/; + var currentUser = { _id: '123' }; + + session.user = currentUser; + $rootScope.$broadcast('avatar:updated', currentUser); + $rootScope.$digest(); expect(element.find('.header-avatar').attr('ng-src')).to.match(regexpAvatarUrl); }); diff --git a/src/frontend/js/modules/header/profile-menu/profile-menu.controller.js b/src/frontend/js/modules/header/profile-menu/profile-menu.controller.js index 88a5b4fd..eca314d9 100644 --- a/src/frontend/js/modules/header/profile-menu/profile-menu.controller.js +++ b/src/frontend/js/modules/header/profile-menu/profile-menu.controller.js @@ -11,7 +11,7 @@ self.openMenu = openMenu; function $onInit() { - self.avatarURL = esnAvatarUrlService.generateForCurrentUser(true); + self.avatarURL = esnAvatarUrlService.generateUrlByUserId(session.user._id, true); $scope.$on('avatar:updated', onAvatarUpdated); } @@ -22,7 +22,7 @@ function onAvatarUpdated(event, user) { if (user && user._id === session.user._id) { - self.avatarURL = esnAvatarUrlService.generateForCurrentUser(true); + self.avatarURL = esnAvatarUrlService.generateUrlByUserId(session.user._id, true); } } }