Refactor email encryption handling in user and contact message models: Introduce utility functions for encoding and decoding encrypted values, simplifying the encryption process. Update the registerUser and handleForgotPassword functions to support multiple encrypted email formats. Enhance the VocabCourseView and VocabLessonView components with new methods for managing language assistant interactions, improving user experience.

This commit is contained in:
Torsten Schulz (local)
2026-03-25 17:41:10 +01:00
parent 519570344c
commit af6e12d80a
5 changed files with 97 additions and 39 deletions

View File

@@ -9,13 +9,13 @@ const ContactMessage = sequelize.define('contact_message', {
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('email', encryptedValue.toString('hex'));
this.setDataValue('email', encryptedValue);
}
},
get() {
const value = this.getDataValue('email');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
return decrypt(value);
}
}
},
@@ -25,13 +25,13 @@ const ContactMessage = sequelize.define('contact_message', {
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('message', encryptedValue.toString('hex'));
this.setDataValue('message', encryptedValue);
}
},
get() {
const value = this.getDataValue('message');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
return decrypt(value);
}
}
},
@@ -41,13 +41,13 @@ const ContactMessage = sequelize.define('contact_message', {
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('name', encryptedValue.toString('hex'));
this.setDataValue('name', encryptedValue);
}
},
get() {
const value = this.getDataValue('name');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
return decrypt(value);
}
}
},
@@ -67,13 +67,13 @@ const ContactMessage = sequelize.define('contact_message', {
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('answer', encryptedValue.toString('hex'));
this.setDataValue('answer', encryptedValue);
}
},
get() {
const value = this.getDataValue('answer');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
return decrypt(value);
}
}
},