@ -1,6 +1,7 @@
using System ;
using System ;
using Microsoft.Extensions.Logging ;
using Microsoft.Extensions.Logging ;
using Microsoft.Extensions.Logging.Abstractions ;
using Microsoft.Extensions.Logging.Abstractions ;
using Microsoft.Extensions.Options ;
using Volo.Abp.DependencyInjection ;
using Volo.Abp.DependencyInjection ;
using Volo.Abp.Security.Encryption ;
using Volo.Abp.Security.Encryption ;
@ -10,10 +11,12 @@ public class SettingEncryptionService : ISettingEncryptionService, ITransientDep
{
{
protected IStringEncryptionService StringEncryptionService { get ; }
protected IStringEncryptionService StringEncryptionService { get ; }
public ILogger < SettingEncryptionService > Logger { get ; set ; }
public ILogger < SettingEncryptionService > Logger { get ; set ; }
protected IOptions < AbpSettingOptions > Options { get ; }
public SettingEncryptionService ( IStringEncryptionService stringEncryptionService )
public SettingEncryptionService ( IStringEncryptionService stringEncryptionService , IOptions < AbpSettingOptions > options )
{
{
StringEncryptionService = stringEncryptionService ;
StringEncryptionService = stringEncryptionService ;
Options = options ;
Logger = NullLogger < SettingEncryptionService > . Instance ;
Logger = NullLogger < SettingEncryptionService > . Instance ;
}
}
@ -40,7 +43,14 @@ public class SettingEncryptionService : ISettingEncryptionService, ITransientDep
}
}
catch ( Exception e )
catch ( Exception e )
{
{
if ( Options . Value . ReturnOriginalValueIfDecryptFailed )
{
Logger . LogWarning ( e , "Failed to decrypt the setting: {0}. Returning the original value..." , settingDefinition . Name ) ;
return encryptedValue ;
}
Logger . LogException ( e ) ;
Logger . LogException ( e ) ;
return string . Empty ;
return string . Empty ;
}
}
}
}