websockets implemented

This commit is contained in:
Torsten Schulz
2024-12-04 19:08:26 +01:00
parent d46a51db38
commit 069c97fa90
64 changed files with 2488 additions and 562 deletions

View File

@@ -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'));
}
}
});