Ability to work without encryption in db

This commit is contained in:
Romaric Mourgues
2023-04-24 17:24:31 +02:00
parent b6420f280c
commit a454875602
2 changed files with 18 additions and 15 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"database": { "database": {
"secret": "ab63bb3e90c0271c9a1c06651a7c0967eab8851a7a897766", "secret": "",
"mongodb": { "mongodb": {
"uri": "mongodb://mongo:27017" "uri": "mongodb://mongo:27017"
}, },
+4 -1
View File
@@ -19,6 +19,7 @@ export type CryptoResult = {
}; };
export function decrypt(data: string, encryptionKey: string): CryptoResult { export function decrypt(data: string, encryptionKey: string): CryptoResult {
if (encryptionKey) {
let result = v2.decrypt(data, encryptionKey); let result = v2.decrypt(data, encryptionKey);
if (result.done) { if (result.done) {
return result; return result;
@@ -33,8 +34,9 @@ export function decrypt(data: string, encryptionKey: string): CryptoResult {
if (result.done) { if (result.done) {
return result; return result;
} }
}
return result; return { data, done: true };
} }
export function md5(value: string): string { export function md5(value: string): string {
@@ -46,5 +48,6 @@ export function encrypt(
encryptionKey: any, encryptionKey: any,
options: { disableSalts?: boolean } = {}, options: { disableSalts?: boolean } = {},
): CryptoResult { ): CryptoResult {
if (!encryptionKey) return value;
return v2.encrypt(value, encryptionKey, options); return v2.encrypt(value, encryptionKey, options);
} }