spee.ch/models/user.js

30 lines
567 B
JavaScript
Raw Normal View History

2017-09-16 17:50:22 -07:00
module.exports = (sequelize, { STRING }) => {
2017-09-15 14:41:47 -07:00
const User = sequelize.define(
2017-09-16 17:50:22 -07:00
'User',
2017-09-15 14:41:47 -07:00
{
2017-09-25 20:30:45 -07:00
userName: {
2017-09-15 14:41:47 -07:00
type : STRING,
allowNull: false,
},
password: {
type : STRING,
allowNull: false,
},
},
{
freezeTableName: true,
}
2017-09-18 10:14:06 -07:00
);
2017-09-15 14:41:47 -07:00
User.associate = db => {
2017-09-25 22:49:27 -07:00
User.hasOne(db.Channel);
2017-09-15 14:41:47 -07:00
};
2017-09-18 10:14:06 -07:00
User.prototype.validPassword = (givenpassword, thispassword) => {
console.log(`${givenpassword} === ${thispassword}`);
return (givenpassword === thispassword);
};
2017-09-15 14:41:47 -07:00
return User;
};