mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
#18507: Allowing an invalid email password to be resetted
Work Item: 18507 --HG-- branch : 1.x
This commit is contained in:
parent
3dfda4aa2c
commit
98f264a5e7
@ -6,6 +6,7 @@ using Orchard.Email.Models;
|
|||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
using Orchard.Logging;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.Email.Handlers {
|
namespace Orchard.Email.Handlers {
|
||||||
@ -15,6 +16,8 @@ namespace Orchard.Email.Handlers {
|
|||||||
|
|
||||||
public SmtpSettingsPartHandler(IRepository<SmtpSettingsPartRecord> repository, IEncryptionService encryptionService) {
|
public SmtpSettingsPartHandler(IRepository<SmtpSettingsPartRecord> repository, IEncryptionService encryptionService) {
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
|
Logger = NullLogger.Instance;
|
||||||
|
|
||||||
_encryptionService = encryptionService;
|
_encryptionService = encryptionService;
|
||||||
Filters.Add(new ActivatingFilter<SmtpSettingsPart>("Site"));
|
Filters.Add(new ActivatingFilter<SmtpSettingsPart>("Site"));
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
@ -22,8 +25,19 @@ namespace Orchard.Email.Handlers {
|
|||||||
OnLoaded<SmtpSettingsPart>(LazyLoadHandlers);
|
OnLoaded<SmtpSettingsPart>(LazyLoadHandlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
void LazyLoadHandlers(LoadContentContext context, SmtpSettingsPart part) {
|
void LazyLoadHandlers(LoadContentContext context, SmtpSettingsPart part) {
|
||||||
part.PasswordField.Getter(() => String.IsNullOrWhiteSpace(part.Record.Password) ? String.Empty : Encoding.UTF8.GetString(_encryptionService.Decode(Convert.FromBase64String(part.Record.Password))));
|
part.PasswordField.Getter(() => {
|
||||||
|
try {
|
||||||
|
return String.IsNullOrWhiteSpace(part.Record.Password) ? String.Empty : Encoding.UTF8.GetString(_encryptionService.Decode(Convert.FromBase64String(part.Record.Password)));
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Logger.Error("The email password could not be decrypted. It might be corrupted, try to reset it.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
part.PasswordField.Setter(value => part.Record.Password = String.IsNullOrWhiteSpace(value) ? String.Empty : Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(value))));
|
part.PasswordField.Setter(value => part.Record.Password = String.IsNullOrWhiteSpace(value) ? String.Empty : Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(value))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user