port most backend functionality, further cleanups, basic electron support

This commit is contained in:
Lukas F. Hartmann
2018-04-12 16:38:48 +02:00
parent 8dc48a84ba
commit 08b81d5ff4
19 changed files with 331 additions and 372 deletions

View File

@@ -198,6 +198,48 @@ module.exports = {
}),
init: function() {
User = this.User;
Session = this.Session;
Space = this.Space;
Artifact = this.Artifact;
Message = this.Message;
Membership = this.Membership;
Space.belongsTo(User, {
foreignKey: {
name: 'creator_id'
},
as: 'creator'
});
Artifact.belongsTo(User, {
foreignKey: {
name: 'user_id'
},
as: 'user'
});
Artifact.belongsTo(Space, {
foreignKey: {
name: 'space_id'
},
as: 'space'
});
Message.belongsTo(User, {
foreignKey: {
name: 'user_id'
},
as: 'user'
});
Message.belongsTo(Space, {
foreignKey: {
name: 'space_id'
},
as: 'space'
});
sequelize.sync();
},
@@ -222,7 +264,6 @@ module.exports = {
});
} else {
// reached the top
var role = prevRole;
space.memberships = currentMemberships;
@@ -252,10 +293,10 @@ module.exports = {
},
findUserBySessionToken: (token, cb) => {
db.Session.findOne({where: {token: token}})
Session.findOne({where: {token: token}})
.then(session => {
if (!session) cb(null, null)
else db.User.findOne({where: {_id: session.user_id}})
else User.findOne({where: {_id: session.user_id}})
.then(user => {
cb(null, user)
})