diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-10-31 10:27:20 +0100 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-10-31 12:49:58 +0100 |
commit | 2b134ff7a986eb97f8ec360321be284a7a8ea11e (patch) | |
tree | 0ff579909b402db5916b66ec7bc7469534881a15 /sandstorm.js | |
parent | 3507c6565bb16b5f45c6f269f7376902f8b1ff37 (diff) | |
parent | 41b23f88aea0f421226f92b081cdb1b61c64bde4 (diff) | |
download | wekan-2b134ff7a986eb97f8ec360321be284a7a8ea11e.tar.gz wekan-2b134ff7a986eb97f8ec360321be284a7a8ea11e.tar.bz2 wekan-2b134ff7a986eb97f8ec360321be284a7a8ea11e.zip |
Merge branch 'devel' into minicard-editor
Conflicts:
client/components/lists/listBody.js
Diffstat (limited to 'sandstorm.js')
-rw-r--r-- | sandstorm.js | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/sandstorm.js b/sandstorm.js index 97d42bdf..65f24866 100644 --- a/sandstorm.js +++ b/sandstorm.js @@ -21,20 +21,13 @@ if (isSandstorm && Meteor.isServer) { permission: 'public', }; - // This function should probably be handled by `accounts-sandstorm` but - // apparently meteor-core misses an API to handle that cleanly, cf. - // https://github.com/meteor/meteor/blob/ff783e9a12ffa04af6fd163843a563c9f4bbe8c1/packages/accounts-base/accounts_server.js#L1143 - function updateUserAvatar(userId, avatarUrl) { - Users.findOne(userId).setAvatarUrl(avatarUrl); - } - function updateUserPermissions(userId, permissions) { - const isActive = permissions.indexOf('participate') > -1; - const isAdmin = permissions.indexOf('configure') > -1; + const isActive = permissions.includes('participate'); + const isAdmin = permissions.includes('configure'); const permissionDoc = { userId, isActive, isAdmin }; const boardMembers = Boards.findOne(sandstormBoard._id).members; - const memberIndex = _.indexOf(_.pluck(boardMembers, 'userId'), userId); + const memberIndex = _.pluck(boardMembers, 'userId').indexOf(userId); let modifier; if (memberIndex > -1) @@ -55,7 +48,8 @@ if (isSandstorm && Meteor.isServer) { // and the home page was accessible by pressing the back button of the // browser, a server-side redirection solves both of these issues. // - // XXX Maybe sandstorm manifest could provide some kind of "home URL"? + // XXX Maybe the sandstorm http-bridge could provide some kind of "home URL" + // in the manifest? const base = req.headers['x-sandstorm-base-path']; // XXX If this routing scheme changes, this will break. We should generate // the location URL using the router, but at the time of writing, the @@ -68,20 +62,14 @@ if (isSandstorm && Meteor.isServer) { res.end(); // `accounts-sandstorm` populate the Users collection when new users - // accesses the document, but in case a already known user come back, we + // 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. const user = Users.findOne({ 'services.sandstorm.id': req.headers['x-sandstorm-user-id'], }); if (user) { - const userId = user._id; - const avatarUrl = req.headers['x-sandstorm-user-picture']; - const permissions = req.headers['x-sandstorm-permissions'].split(',') || []; - - // XXX The user may also change his name, we should handle it. - updateUserAvatar(userId, avatarUrl); - updateUserPermissions(userId, permissions); + updateUserPermissions(user._id, user.permissions); } }); @@ -90,6 +78,8 @@ if (isSandstorm && Meteor.isServer) { // unique board document. Note that when the `Users.after.insert` hook is // called, the user is inserted into the database but not connected. So // despite the appearances `userId` is null in this block. + // + // XXX We should support the `preferredHandle` exposed by Sandstorm Users.after.insert((userId, doc) => { if (!Boards.findOne(sandstormBoard._id)) { Boards.insert(sandstormBoard, {validate: false}); @@ -101,6 +91,15 @@ if (isSandstorm && Meteor.isServer) { updateUserPermissions(doc._id, doc.services.sandstorm.permissions); }); + + // LibreBoard v0.8 didn’t implement the Sandstorm sharing model and instead + // kept the visibility setting (“public” or “private”) in the UI as does the + // main Meteor application. We need to enforce “public” visibility as the + // sharing is now handled by Sandstorm. + // See https://github.com/wekan/wekan/issues/346 + Migrations.add('enforce-public-visibility-for-sandstorm', () => { + Boards.update('sandstorm', { $set: { permission: 'public' }}); + }); } if (isSandstorm && Meteor.isClient) { @@ -110,7 +109,7 @@ if (isSandstorm && Meteor.isClient) { // sandstorm client to return relative paths instead of absolutes. const _absoluteUrl = Meteor.absoluteUrl; const _defaultOptions = Meteor.absoluteUrl.defaultOptions; - Meteor.absoluteUrl = (path, options) => { + Meteor.absoluteUrl = (path, options) => { // eslint-disable-line meteor/core const url = _absoluteUrl(path, options); return url.replace(/^https?:\/\/127\.0\.0\.1:[0-9]{2,5}/, ''); }; |