Ability to work without encryption in db
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"database": {
|
"database": {
|
||||||
"secret": "ab63bb3e90c0271c9a1c06651a7c0967eab8851a7a897766",
|
"secret": "",
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
"uri": "mongodb://mongo:27017"
|
"uri": "mongodb://mongo:27017"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,22 +19,24 @@ export type CryptoResult = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function decrypt(data: string, encryptionKey: string): CryptoResult {
|
export function decrypt(data: string, encryptionKey: string): CryptoResult {
|
||||||
let result = v2.decrypt(data, encryptionKey);
|
if (encryptionKey) {
|
||||||
if (result.done) {
|
let result = v2.decrypt(data, encryptionKey);
|
||||||
return result;
|
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);
|
return { data, done: true };
|
||||||
if (result.done) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = legacy.decrypt(data, encryptionKey);
|
|
||||||
if (result.done) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user