Ability to work without encryption in db
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"database": {
|
||||
"secret": "ab63bb3e90c0271c9a1c06651a7c0967eab8851a7a897766",
|
||||
"secret": "",
|
||||
"mongodb": {
|
||||
"uri": "mongodb://mongo:27017"
|
||||
},
|
||||
|
||||
@@ -19,22 +19,24 @@ export type CryptoResult = {
|
||||
};
|
||||
|
||||
export function decrypt(data: string, encryptionKey: string): CryptoResult {
|
||||
let result = v2.decrypt(data, encryptionKey);
|
||||
if (result.done) {
|
||||
return result;
|
||||
if (encryptionKey) {
|
||||
let result = v2.decrypt(data, encryptionKey);
|
||||
if (result.done) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = v1.decrypt(data, encryptionKey);
|
||||
if (result.done) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = legacy.decrypt(data, encryptionKey);
|
||||
if (result.done) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = v1.decrypt(data, encryptionKey);
|
||||
if (result.done) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = legacy.decrypt(data, encryptionKey);
|
||||
if (result.done) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
return { data, done: true };
|
||||
}
|
||||
|
||||
export function md5(value: string): string {
|
||||
@@ -46,5 +48,6 @@ export function encrypt(
|
||||
encryptionKey: any,
|
||||
options: { disableSalts?: boolean } = {},
|
||||
): CryptoResult {
|
||||
if (!encryptionKey) return value;
|
||||
return v2.encrypt(value, encryptionKey, options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user