mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Fix avatar support on Sanstorm
The bug comes for 9154b06
which this commit partially reverts. The
synchronization between the user document profile and the Sandstorm
HTTP headers is still not perfect. Having a clean model may requires
the `accounts-sandstorm` to expose a hook to modify the user document
just after the `services.sandstorm` credentials are updated.
Fixes #460
This commit is contained in:
parent
15e692a7d2
commit
0587223489
3 changed files with 16 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
template(name="userAvatar")
|
||||
a.member.js-member(title="{{userData.profile.fullname}} ({{userData.username}})")
|
||||
if userData.getAvatarUrl
|
||||
img.avatar.avatar-image(src=userData.getAvatarUrl)
|
||||
if userData.profile.avatarUrl
|
||||
img.avatar.avatar-image(src=userData.profile.avatarUrl)
|
||||
else
|
||||
+userAvatarInitials(userId=userData._id)
|
||||
|
||||
|
|
|
@ -47,19 +47,6 @@ Users.helpers({
|
|||
return _.contains(invitedBoards, boardId);
|
||||
},
|
||||
|
||||
getAvatarUrl() {
|
||||
// Although we put the avatar picture URL in the `profile` object, we need
|
||||
// to support Sandstorm which put in the `picture` attribute by default.
|
||||
// XXX Should we move both cases to `picture`?
|
||||
if (this.picture) {
|
||||
return this.picture;
|
||||
} else if (this.profile && this.profile.avatarUrl) {
|
||||
return this.profile.avatarUrl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
getInitials() {
|
||||
const profile = this.profile || {};
|
||||
if (profile.initials)
|
||||
|
|
15
sandstorm.js
15
sandstorm.js
|
@ -65,11 +65,23 @@ if (isSandstorm && Meteor.isServer) {
|
|||
// accesses the document, but in case a already known user comes back, we
|
||||
// need to update his associated document to match the request HTTP headers
|
||||
// informations.
|
||||
// XXX We need to update this document even if the initial route is not `/`.
|
||||
// Unfortuanlty I wasn't able to make the Webapp.rawConnectHandlers solution
|
||||
// work.
|
||||
const user = Users.findOne({
|
||||
'services.sandstorm.id': req.headers['x-sandstorm-user-id'],
|
||||
});
|
||||
if (user) {
|
||||
updateUserPermissions(user._id, user.permissions);
|
||||
// XXX At this point the user.services.sandstorm credentials haven't been
|
||||
// updated, which mean that the user will have to restart the application
|
||||
// a second time to see its updated name and avatar.
|
||||
Users.update(user._id, {
|
||||
$set: {
|
||||
'profile.fullname': user.services.sandstorm.name,
|
||||
'profile.avatarUrl': user.services.sandstorm.picture,
|
||||
},
|
||||
});
|
||||
updateUserPermissions(user._id, user.services.sandstorm.permissions);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -109,6 +121,7 @@ if (isSandstorm && Meteor.isServer) {
|
|||
$set: {
|
||||
username: generateUniqueUsername(username, appendNumber),
|
||||
'profile.fullname': doc.services.sandstorm.name,
|
||||
'profile.avatarUrl': doc.services.sandstorm.picture,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue