Authentication #170

Merged
bones7242 merged 43 commits from authentication into master 2017-09-29 02:29:22 +02:00
5 changed files with 64 additions and 0 deletions
Showing only changes of commit 242248c4f6 - Show all commits

5
auth/authentication.js Normal file
View file

@ -0,0 +1,5 @@
module.exports = {
isAuthenticated (req, res, next) {
},
};

View file

@ -87,5 +87,15 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
freezeTableName: true,
}
);
Certificate.associate = db => {
Certificate.belongsTo(db.User, {
onDelete : 'cascade',
foreignKey: {
allowNull: true,
},
});
};
return Certificate;
};

View file

@ -140,5 +140,14 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
}
);
Claim.associate = db => {
Claim.belongsTo(db.File, {
onDelete : 'cascade',
foreignKey: {
allowNull: true,
},
});
};
return Claim;
};

View file

@ -52,6 +52,13 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => {
File.associate = db => {
File.hasMany(db.Request);
File.belongsTo(db.User, {
onDelete : 'cascade',
foreignKey: {
allowNull: true,
},
});
File.hasOne(db.Claim);
};
return File;

33
models/user.js Normal file
View file

@ -0,0 +1,33 @@
module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => {
const User = sequelize.define(
'User',
kauffj commented 2017-09-22 15:47:09 +02:00 (Migrated from github.com)
Review

Is this a "User" or a "Channel"? I understand these have a 1-1 correspondence right now, but these are likely not the same thing as spee.ch continues to grow/evolve.

I think it is likely that this should be two tables, a User table and a Channel table, with Channel having a foreign key to User.

In addition to being more semantic, this would facilitate growth into a design where one user can access multiple channels from a single session/login without a tricky later refactor.

Is this a "User" or a "Channel"? I understand these have a 1-1 correspondence right now, but these are likely not the same thing as spee.ch continues to grow/evolve. I think it is likely that this should be two tables, a User table and a Channel table, with Channel having a foreign key to User. In addition to being more semantic, this would facilitate growth into a design where one user can access multiple channels from a single session/login without a tricky later refactor.
bones7242 commented 2017-09-26 07:40:54 +02:00 (Migrated from github.com)
Review

per our conversation today, I am updating the db to include both User and Channel tables

per our conversation today, I am updating the db to include both User and Channel tables
{
channelName: {
type : STRING,
allowNull: false,
},
channelClaimId: {
type : STRING,
allowNull: false,
},
password: {
type : STRING,
allowNull: false,
},
email: {
type : STRING,
allowNull: false,
},
},
{
freezeTableName: true,
}
);
User.associate = db => {
User.hasMany(db.File);
User.hasOne(db.Certificate);
};
return User;
};