Add warning to configure e-mail server (#2024)

Adds a warning to configure the e-mail server before "Requires a confirmation mail for registering" checkbox can be checked if e-mail server is not configured.

close #1889
This commit is contained in:
Umar Bolatov
2020-11-02 21:53:49 -08:00
committed by GitHub
parent ef3f314754
commit b406f52670

View File

@@ -1,5 +1,7 @@
@using BTCPayServer.Services
@using BTCPayServer.Services.Mails;
@model BTCPayServer.Services.PoliciesSettings
@inject BTCPayServer.Services.SettingsRepository _SettingsRepository
@{
ViewData.SetActivePageAndTitle(ServerNavPages.Policies);
}
@@ -14,9 +16,22 @@
<form method="post">
<div class="form-group">
<div class="form-check">
<input asp-for="RequiresConfirmedEmail" type="checkbox" class="form-check-input"/>
@{
var emailSettings = (await _SettingsRepository.GetSettingAsync<EmailSettings>()) ?? new EmailSettings();
/**
* The "|| Model.RequiresConfirmedEmail" check is for the case when a user had checked
* the checkbox without first configuring the e-mail settings so that they can uncheck it.
**/
var isEmailConfigured = emailSettings.IsComplete() || Model.RequiresConfirmedEmail;
}
<input asp-for="RequiresConfirmedEmail" type="checkbox" class="form-check-input" disabled="@(isEmailConfigured ? null : "disabled")" />
<label asp-for="RequiresConfirmedEmail" class="form-check-label"></label>
<span asp-validation-for="RequiresConfirmedEmail" class="text-danger"></span>
@if (!isEmailConfigured) {
<div>
<span class="text-secondary">Your email server has not been configured. <a asp-controller="Server" asp-action="Emails">Please configure it first.</a></span>
</div>
}
</div>
<div class="form-check">
<input asp-for="LockSubscription" type="checkbox" class="form-check-input"/>