Registration and activation

This commit is contained in:
Torsten Schulz
2024-07-20 20:43:18 +02:00
parent 3880a265eb
commit bbf4a2deb3
51 changed files with 3016 additions and 69 deletions

View File

@@ -0,0 +1,49 @@
import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';
import bcrypt from 'bcrypt';
const User = sequelize.define('user', {
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
set(value) {
this.setDataValue('email', bcrypt.hashSync(value, 10));
}
},
username: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
password: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
this.setDataValue('password', bcrypt.hashSync(value, 10));
}
},
registrationDate: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
active: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
resetToken: {
type: DataTypes.UUID,
allowNull: true
},
hashedId: {
type: DataTypes.STRING,
allowNull: true
}
}, {
tableName: 'user',
schema: 'community',
underscored: true,
});
export default User;