mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Fix set email screen
This commit is contained in:
@@ -241,10 +241,16 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
if (command == "Test")
|
if (command == "Test")
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return View(model);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(model.Settings.From)
|
||||||
|
|| string.IsNullOrWhiteSpace(model.TestEmail)
|
||||||
|
|| string.IsNullOrWhiteSpace(model.Settings.Login)
|
||||||
|
|| string.IsNullOrWhiteSpace(model.Settings.Server))
|
||||||
|
{
|
||||||
|
model.StatusMessage = "Error: Required fields missing";
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
var client = model.Settings.CreateSmtpClient();
|
var client = model.Settings.CreateSmtpClient();
|
||||||
await client.SendMailAsync(model.Settings.From, model.TestEmail, "BTCPay test", "BTCPay test");
|
await client.SendMailAsync(model.Settings.From, model.TestEmail, "BTCPay test", "BTCPay test");
|
||||||
model.StatusMessage = "Email sent to " + model.TestEmail + ", please, verify you received it";
|
model.StatusMessage = "Email sent to " + model.TestEmail + ", please, verify you received it";
|
||||||
@@ -255,21 +261,12 @@ namespace BTCPayServer.Controllers
|
|||||||
}
|
}
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
else if(command == "Save")
|
else // if(command == "Save")
|
||||||
{
|
{
|
||||||
ModelState.Remove(nameof(model.TestEmail));
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return View(model);
|
|
||||||
await _SettingsRepository.UpdateSetting(model.Settings);
|
await _SettingsRepository.UpdateSetting(model.Settings);
|
||||||
model.StatusMessage = "Email settings saved";
|
model.StatusMessage = "Email settings saved";
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
await _SettingsRepository.UpdateSetting(new EmailSettings());
|
|
||||||
model.StatusMessage = "Email settings cleared";
|
|
||||||
return View(model);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ namespace BTCPayServer.Models.ServerViewModels
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required]
|
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
public string TestEmail
|
public string TestEmail
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,30 +10,25 @@ namespace BTCPayServer.Services.Mails
|
|||||||
{
|
{
|
||||||
public class EmailSettings
|
public class EmailSettings
|
||||||
{
|
{
|
||||||
[Required]
|
|
||||||
public string Server
|
public string Server
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int? Port
|
public int? Port
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required]
|
|
||||||
public String Login
|
public String Login
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Required]
|
|
||||||
public String Password
|
public String Password
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
public string From
|
public string From
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,11 +53,11 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="TestEmail"></label>
|
<label asp-for="TestEmail"></label>
|
||||||
<input asp-for="TestEmail" class="form-control" />
|
<input asp-for="TestEmail" class="form-control" />
|
||||||
|
<span asp-validation-for="TestEmail" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
|
<button type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
|
||||||
<button type="submit" class="btn btn-primary" name="command" value="Test">Test</button>
|
<button type="submit" class="btn btn-primary" name="command" value="Test">Test</button>
|
||||||
<button type="submit" class="btn btn-danger" name="command" value="Clear">Clear</button>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@model BTCPayServer.Models.StoreViewModels.RatesViewModel.RatesViewModel
|
@model BTCPayServer.Models.StoreViewModels.RatesViewModel
|
||||||
@{
|
@{
|
||||||
Layout = "../Shared/_NavLayout.cshtml";
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
ViewData["Title"] = "Rates";
|
ViewData["Title"] = "Rates";
|
||||||
|
|||||||
Reference in New Issue
Block a user