mirror of
https://github.com/wekan/wekan.git
synced 2025-04-20 12:07:11 -04:00
Fix login on Sandstorm by not creating welcome boards
This one is a pretty strange chain of events: * fetching /.sandstorm-login via accounts-sandstorm's rendezvous protocol causes a user to be created in the users collection * models/users.js has hooks to create a board and lists when a user is created * models/activities.js has a hook to create activity entries when a list is created * this hook does not handle not having no boardId, which results in attempting to run the hook with boardId: 'false'. 'false' does not have a title attribute, which causes the whole method call to throw an exception. * This makes the initial login fail. While there may be other bugs, the simple fix is to not create the board and lists when running under Sandstorm, where you only have one board anyway.
This commit is contained in:
parent
87ce042c63
commit
0f62fe0c6e
1 changed files with 21 additions and 15 deletions
|
@ -1,3 +1,7 @@
|
|||
// Sandstorm context is detected using the METEOR_SETTINGS environment variable
|
||||
// in the package definition.
|
||||
const isSandstorm = Meteor.settings && Meteor.settings.public &&
|
||||
Meteor.settings.public.sandstorm;
|
||||
Users = Meteor.users;
|
||||
|
||||
Users.attachSchema(new SimpleSchema({
|
||||
|
@ -394,24 +398,26 @@ if (Meteor.isServer) {
|
|||
return fakeUserId.get() || getUserId();
|
||||
};
|
||||
|
||||
Users.after.insert((userId, doc) => {
|
||||
const fakeUser = {
|
||||
extendAutoValueContext: {
|
||||
userId: doc._id,
|
||||
},
|
||||
};
|
||||
if (!isSandstorm) {
|
||||
Users.after.insert((userId, doc) => {
|
||||
const fakeUser = {
|
||||
extendAutoValueContext: {
|
||||
userId: doc._id,
|
||||
},
|
||||
};
|
||||
|
||||
fakeUserId.withValue(doc._id, () => {
|
||||
// Insert the Welcome Board
|
||||
Boards.insert({
|
||||
title: TAPi18n.__('welcome-board'),
|
||||
permission: 'private',
|
||||
}, fakeUser, (err, boardId) => {
|
||||
fakeUserId.withValue(doc._id, () => {
|
||||
// Insert the Welcome Board
|
||||
Boards.insert({
|
||||
title: TAPi18n.__('welcome-board'),
|
||||
permission: 'private',
|
||||
}, fakeUser, (err, boardId) => {
|
||||
|
||||
['welcome-list1', 'welcome-list2'].forEach((title) => {
|
||||
Lists.insert({ title: TAPi18n.__(title), boardId }, fakeUser);
|
||||
['welcome-list1', 'welcome-list2'].forEach((title) => {
|
||||
Lists.insert({ title: TAPi18n.__(title), boardId }, fakeUser);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue