Skip to content

Commit

Permalink
linagora#152 use personal avatar route compatible with OIDC
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBailly authored and Ba Son PHAM committed Nov 27, 2020
1 parent 3b76bfc commit 9c3796c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/frontend/js/modules/avatar/avatar-url.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
angular.module('esn.avatar')
.factory('esnAvatarUrlService', esnAvatarUrlService);

function esnAvatarUrlService(urlUtils) {
function esnAvatarUrlService($log, urlUtils) {
return {
generateUrl: generateUrl,
generateForCurrentUser: generateForCurrentUser,
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 9c3796c

Please sign in to comment.