diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-12-30 19:16:49 +0100 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-12-30 19:34:18 +0100 |
commit | d9b74131aedd0f263aa7fe35307ee2c6d6e6ab86 (patch) | |
tree | 4c005f8c67ab0c4c4878f9ca13488a461872326c /sandstorm.js | |
parent | f6c01161a02e273b87c9f6cc02d3809b997241ba (diff) | |
download | wekan-d9b74131aedd0f263aa7fe35307ee2c6d6e6ab86.tar.gz wekan-d9b74131aedd0f263aa7fe35307ee2c6d6e6ab86.tar.bz2 wekan-d9b74131aedd0f263aa7fe35307ee2c6d6e6ab86.zip |
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
Diffstat (limited to 'sandstorm.js')
-rw-r--r-- | sandstorm.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sandstorm.js b/sandstorm.js index def07eea..4abe2efb 100644 --- a/sandstorm.js +++ b/sandstorm.js @@ -63,11 +63,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); } }); @@ -107,6 +119,7 @@ if (isSandstorm && Meteor.isServer) { $set: { username: generateUniqueUsername(username, appendNumber), 'profile.fullname': doc.services.sandstorm.name, + 'profile.avatarUrl': doc.services.sandstorm.picture, }, }); |