Add check for empty theme URI before saving theme settings

This commit is contained in:
Umar Bolatov 2021-09-06 20:31:18 -07:00 committed by Andrew Camilleri
parent 06db29dd43
commit 5faa756f1c

View File

@ -979,13 +979,21 @@ namespace BTCPayServer.Controllers
var data = await _SettingsRepository.GetSettingAsync<ThemeSettings>() ?? new ThemeSettings();
return View(data);
}
[Route("server/theme")]
[HttpPost]
public async Task<IActionResult> Theme(ThemeSettings settings)
{
await _SettingsRepository.UpdateSetting(settings);
TempData[WellKnownTempData.SuccessMessage] = "Theme settings updated successfully";
if (settings.CustomTheme && !Uri.IsWellFormedUriString(settings.CssUri, UriKind.RelativeOrAbsolute))
{
TempData[WellKnownTempData.ErrorMessage] = "Please provide a non-empty theme URI";
}
else
{
await _SettingsRepository.UpdateSetting(settings);
TempData[WellKnownTempData.SuccessMessage] = "Theme settings updated successfully";
}
return View(settings);
}