diff options
Diffstat (limited to 'models/users.js')
-rw-r--r-- | models/users.js | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/models/users.js b/models/users.js index a04021c1..6e83337e 100644 --- a/models/users.js +++ b/models/users.js @@ -43,7 +43,9 @@ Users.attachSchema(new SimpleSchema({ optional: true, autoValue() { // eslint-disable-line consistent-return if (this.isInsert && !this.isSet) { - return {}; + return { + boardView: 'board-view-lists', + }; } }, }, @@ -95,6 +97,15 @@ Users.attachSchema(new SimpleSchema({ type: String, optional: true, }, + 'profile.boardView': { + type: String, + optional: true, + allowedValues: [ + 'board-view-lists', + 'board-view-swimlanes', + 'board-view-cal', + ], + }, services: { type: Object, optional: true, @@ -329,6 +340,14 @@ Users.mutations({ setShowCardsCountAt(limit) { return {$set: {'profile.showCardsCountAt': limit}}; }, + + setBoardView(view) { + return { + $set : { + 'profile.boardView': view, + }, + }; + }, }); Meteor.methods({ @@ -508,9 +527,14 @@ if (Meteor.isServer) { throw new Meteor.Error('error-invitation-code-not-exist', 'The invitation code doesn\'t exist'); } else { user.profile = {icode: options.profile.invitationcode}; - } + user.profile.boardView = 'board-view-lists'; - return user; + // Deletes the invitation code after the user was created successfully. + setTimeout(Meteor.bindEnvironment(() => { + InvitationCodes.remove({'_id': invitationCode._id}); + }), 200); + return user; + } }); } @@ -579,10 +603,11 @@ if (Meteor.isServer) { Swimlanes.insert({ title: TAPi18n.__('welcome-swimlane'), boardId, + sort: 1, }, fakeUser); - ['welcome-list1', 'welcome-list2'].forEach((title) => { - Lists.insert({title: TAPi18n.__(title), boardId}, fakeUser); + ['welcome-list1', 'welcome-list2'].forEach((title, titleIndex) => { + Lists.insert({title: TAPi18n.__(title), boardId, sort: titleIndex}, fakeUser); }); }); }); @@ -624,9 +649,20 @@ if (Meteor.isServer) { }); } - // USERS REST API if (Meteor.isServer) { + // Middleware which checks that API is enabled. + JsonRoutes.Middleware.use(function (req, res, next) { + const api = req.url.search('api'); + if (api === 1 && process.env.WITH_API === 'true' || api === -1){ + return next(); + } + else { + res.writeHead(301, {Location: '/'}); + return res.end(); + } + }); + JsonRoutes.add('GET', '/api/user', function(req, res) { try { Authentication.checkLoggedIn(req.userId); @@ -767,4 +803,3 @@ if (Meteor.isServer) { } }); } - |