From ecc0a948d742cabbf7b2fc6610b0f9639f84143d Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Sat, 2 Nov 2024 10:15:32 +0800 Subject: [PATCH 1/4] Remove Reset endpoint from SettingsController The Reset endpoint, which handled system reset requests by logging a warning, clearing all data from the BlogDbContext, stopping the application, and returning an HTTP 202 Accepted response, has been removed from the SettingsController class. This change eliminates the ability to reset the system via this controller. --- src/Moonglade.Web/Controllers/SettingsController.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Moonglade.Web/Controllers/SettingsController.cs b/src/Moonglade.Web/Controllers/SettingsController.cs index 2241a6a85..857833cb7 100644 --- a/src/Moonglade.Web/Controllers/SettingsController.cs +++ b/src/Moonglade.Web/Controllers/SettingsController.cs @@ -173,18 +173,6 @@ public async Task SocialLink(SocialLinkSettingsJsonModel model) return NoContent(); } - [HttpPost("reset")] - [ProducesResponseType(StatusCodes.Status202Accepted)] - public async Task Reset(BlogDbContext context, IHostApplicationLifetime applicationLifetime) - { - logger.LogWarning($"System reset is requested by '{User.Identity?.Name}', IP: {Helper.GetClientIP(HttpContext)}."); - - await context.ClearAllData(); - - applicationLifetime.StopApplication(); - return Accepted(); - } - [HttpPost("custom-css")] [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status400BadRequest)] From bfe480594b82fc2ea13408a017bc706aceb80cbe Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Sat, 2 Nov 2024 10:15:53 +0800 Subject: [PATCH 2/4] Remove specific entries from resource files Removed the following entries from `Program.de-DE.resx`, `Program.ja-JP.resx`, `Program.zh-Hans.resx`, and `Program.zh-Hant.resx`: - "Are you ABSOLUTELY sure? ALL data and configuration will be erased!" - "Erase all data and configuration." - "Reset" - "System Reset" --- src/Moonglade.Web/Resources/Program.de-DE.resx | 12 ------------ src/Moonglade.Web/Resources/Program.ja-JP.resx | 12 ------------ src/Moonglade.Web/Resources/Program.zh-Hans.resx | 12 ------------ src/Moonglade.Web/Resources/Program.zh-Hant.resx | 9 --------- 4 files changed, 45 deletions(-) diff --git a/src/Moonglade.Web/Resources/Program.de-DE.resx b/src/Moonglade.Web/Resources/Program.de-DE.resx index 9507bab84..494841376 100644 --- a/src/Moonglade.Web/Resources/Program.de-DE.resx +++ b/src/Moonglade.Web/Resources/Program.de-DE.resx @@ -168,9 +168,6 @@ Archiv - - Sind sie WIRKLICH sicher? Alle Daten und Konfigurationen werden gelöscht! - Möchten Sie die Webseite wirklich neu starten? Alle aktuellen Anfragen werden verworfen. @@ -393,9 +390,6 @@ Umgebung - - Alle Daten und Konfigurationen löschen. - Daten exportieren @@ -606,9 +600,6 @@ Antworten - - Zurücksetzen - Passwort zurücksetzen @@ -696,9 +687,6 @@ System - - System zurücksetzen - Tagname diff --git a/src/Moonglade.Web/Resources/Program.ja-JP.resx b/src/Moonglade.Web/Resources/Program.ja-JP.resx index 34915a0a5..9fab17779 100644 --- a/src/Moonglade.Web/Resources/Program.ja-JP.resx +++ b/src/Moonglade.Web/Resources/Program.ja-JP.resx @@ -168,9 +168,6 @@ - - 本当に本当ですか? すべてのデータと設定が消去されます。 - あなたはあなたのウェブサイトを再起動してもよろしいですか? 現在のすべての要求が終了します。 @@ -393,9 +390,6 @@ 環境 - - すべてのデータと設定を消去 - データのエクスポート @@ -606,9 +600,6 @@ 答える - - リセット - パスワードを再設定する @@ -696,9 +687,6 @@ - - システムリセット - タグ名 diff --git a/src/Moonglade.Web/Resources/Program.zh-Hans.resx b/src/Moonglade.Web/Resources/Program.zh-Hans.resx index 4cc9f2abd..3054f33bd 100644 --- a/src/Moonglade.Web/Resources/Program.zh-Hans.resx +++ b/src/Moonglade.Web/Resources/Program.zh-Hans.resx @@ -171,9 +171,6 @@ 归档 - - 你真的确定吗?所有数据和配置都将灰飞烟灭! - 你确定要重启网站吗?所有当前请求都会被终止。 @@ -399,9 +396,6 @@ 环境 - - 抹除所有数据及配置 - 导出数据 @@ -630,9 +624,6 @@ 回复 - - 重置 - 重置密码 @@ -723,9 +714,6 @@ 系统 - - 系统重置 - 标签名 diff --git a/src/Moonglade.Web/Resources/Program.zh-Hant.resx b/src/Moonglade.Web/Resources/Program.zh-Hant.resx index 24d3bf86a..42858595e 100644 --- a/src/Moonglade.Web/Resources/Program.zh-Hant.resx +++ b/src/Moonglade.Web/Resources/Program.zh-Hant.resx @@ -171,9 +171,6 @@ 歸檔時間軸 - - 你真的確定嗎?所有數據和配置都將灰飛煙滅! - 你確定要重啟網站嗎?所有當前請求都會被終止。 @@ -624,9 +621,6 @@ 回復 - - 重置 - 重置密碼 @@ -717,9 +711,6 @@ 系統 - - 系統重置 - 標籤名 From 117258f8e093e577a463651530a28f9d9c06c0a7 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Sat, 2 Nov 2024 10:16:10 +0800 Subject: [PATCH 3/4] Remove "System Reset" functionality The following changes have been made: - Removed the JavaScript event listener for the `.btn-reset` button. - Removed the HTML block containing the "System Reset" button and its description. - Removed the `_ResetModal` partial view for the reset confirmation dialog. --- .../Pages/Settings/Advanced.cshtml | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/Moonglade.Web/Pages/Settings/Advanced.cshtml b/src/Moonglade.Web/Pages/Settings/Advanced.cshtml index 6ad2d1951..822036d22 100644 --- a/src/Moonglade.Web/Pages/Settings/Advanced.cshtml +++ b/src/Moonglade.Web/Pages/Settings/Advanced.cshtml @@ -30,21 +30,6 @@ }, 1000); } - document.querySelector('.btn-reset').addEventListener('click', function () { - callApi(`/api/settings/reset`, 'POST', {}, () => { }); - - var btnReset = document.querySelector('.btn-reset'); - btnReset.textContent = 'Wait...'; - btnReset.classList.add('disabled'); - btnReset.setAttribute('disabled', 'disabled'); - - startTimer(30, btnReset); - - setTimeout(function () { - location.href = '/'; - }, 30000); - }); - document.querySelector('.btn-check-update').addEventListener('click', function () { document.querySelector('.spinner-border').style.display = 'block'; document.querySelector('.alert-has-new-release').style.display = 'none'; @@ -271,23 +256,6 @@ - -
-
- -
-
- @SharedLocalizer["System Reset"] -
- @SharedLocalizer["Erase all data and configuration."] -
-
- -
@@ -298,5 +266,4 @@ - \ No newline at end of file From b30567b17ace37fa45545e89de9f05316a22c9c5 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Sat, 2 Nov 2024 10:16:19 +0800 Subject: [PATCH 4/4] Remove system reset modal from _ResetModal.cshtml The entire modal dialog for system reset has been removed from the _ResetModal.cshtml file. This includes the modal structure, header, body, and footer, along with the buttons for closing the modal and performing the reset action. --- .../Pages/Settings/_ResetModal.cshtml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/Moonglade.Web/Pages/Settings/_ResetModal.cshtml diff --git a/src/Moonglade.Web/Pages/Settings/_ResetModal.cshtml b/src/Moonglade.Web/Pages/Settings/_ResetModal.cshtml deleted file mode 100644 index 699e6493d..000000000 --- a/src/Moonglade.Web/Pages/Settings/_ResetModal.cshtml +++ /dev/null @@ -1,18 +0,0 @@ - \ No newline at end of file