Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
kfet/models/user.js

33 lines
762 B
JavaScript

"use strict";
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('User', {
username: {
type: DataTypes.STRING,
primaryKey: true
},
passwordHash: {
type: DataTypes.STRING,
set(value) {
if (value)
this.setDataValue("passwordHash", require("crypto").createHash("sha256").update(this.username + value).digest("base64"));
}
},
firstName: {
type: DataTypes.STRING,
allowNull: false,
unique: "userFullName"
},
lastName: {
type: DataTypes.STRING,
allowNull: false,
unique: "userFullName"
}
}, {
tableName: "Users"
});
User.associate = function(models) {
// associations can be defined here
};
return User;
};