websockets implemented
This commit is contained in:
@@ -5,14 +5,27 @@ import crypto from 'crypto';
|
||||
|
||||
const User = sequelize.define('user', {
|
||||
email: {
|
||||
type: DataTypes.BLOB,
|
||||
type: DataTypes.BLOB,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
set(value) {
|
||||
if (value) {
|
||||
this.setDataValue('email', Buffer.from(encrypt(value), 'hex'));
|
||||
const encrypted = encrypt(value);
|
||||
this.setDataValue('email', encrypted);
|
||||
}
|
||||
},
|
||||
get() {
|
||||
const encrypted = this.getDataValue('email');
|
||||
if (encrypted) {
|
||||
return decrypt(encrypted);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
salt: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
defaultValue: () => crypto.randomBytes(16).toString('hex')
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
@@ -58,11 +71,6 @@ const User = sequelize.define('user', {
|
||||
user.hashedId = hashedId;
|
||||
await user.save();
|
||||
}
|
||||
},
|
||||
getterMethods: {
|
||||
email() {
|
||||
return decrypt(this.getDataValue('email').toString('hex'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user