From a85e87d330abe01d617124764890bef92f3db26d Mon Sep 17 00:00:00 2001 From: owenchen Date: Tue, 12 May 2026 15:30:20 +0800 Subject: [PATCH] ow --- CloudBuilder.Core/Request/ServiceRequest.cs | 28 +++++++++---------- CloudBuilder.Security.Gui/MainForm.cs | 1 + CloudBuilder.Security.Gui/MainForm.partial.cs | 5 ++-- .../SecurityUserService.cs | 2 +- .../Security/SecurityUserController.auto.cs | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/CloudBuilder.Core/Request/ServiceRequest.cs b/CloudBuilder.Core/Request/ServiceRequest.cs index 8673e5a..1672fbb 100644 --- a/CloudBuilder.Core/Request/ServiceRequest.cs +++ b/CloudBuilder.Core/Request/ServiceRequest.cs @@ -138,9 +138,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); @@ -188,9 +188,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); @@ -244,9 +244,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); @@ -275,9 +275,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); @@ -306,9 +306,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); @@ -335,9 +335,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); @@ -379,9 +379,9 @@ namespace CloudBuilder.Core.Request if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11); if (response.ReasonPhrase == "Forbidden") - throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors)); + throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION))); - throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors)); + throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors)); } response.EnsureSuccessStatusCode(); diff --git a/CloudBuilder.Security.Gui/MainForm.cs b/CloudBuilder.Security.Gui/MainForm.cs index 17670b0..e7932d4 100644 --- a/CloudBuilder.Security.Gui/MainForm.cs +++ b/CloudBuilder.Security.Gui/MainForm.cs @@ -60,6 +60,7 @@ namespace CloudBuilder.Security.Gui //设置菜单 InitMenu(); //设置欢迎页 + DisplayAbstractPage(typeof(WelcomePage).Name); } catch (ValidatedException ex) diff --git a/CloudBuilder.Security.Gui/MainForm.partial.cs b/CloudBuilder.Security.Gui/MainForm.partial.cs index d3d86bc..2f5e501 100644 --- a/CloudBuilder.Security.Gui/MainForm.partial.cs +++ b/CloudBuilder.Security.Gui/MainForm.partial.cs @@ -22,12 +22,13 @@ namespace CloudBuilder.Security.Gui private void InitMenu() { - if (securityMenuData.SecurityFunctionDisplayDatas == null || securityMenuData.SecurityFunctionDisplayDatas.Count() == 0 || securityMenuData.SecurityFunctionMaps == null || securityMenuData.SecurityFunctionMaps.Count() == 0) + this.mainMenu.Items.Clear(); + + if (securityMenuData == null || securityMenuData.SecurityFunctionDisplayDatas == null || securityMenuData.SecurityFunctionDisplayDatas.Count() == 0 || securityMenuData.SecurityFunctionMaps == null || securityMenuData.SecurityFunctionMaps.Count() == 0) { return; } - this.mainMenu.Items.Clear(); Dictionary menuItems = new Dictionary(); SetMenuItem(); diff --git a/CloudBuilder.Security.Service/SecurityUserService.cs b/CloudBuilder.Security.Service/SecurityUserService.cs index cd593c4..7637bc1 100644 --- a/CloudBuilder.Security.Service/SecurityUserService.cs +++ b/CloudBuilder.Security.Service/SecurityUserService.cs @@ -228,7 +228,7 @@ namespace CloudBuilder.Security.Service } } - [PermissionOperate(name: SecurityPermissionPolicy.SecurityUser, operate: Operate.None)] + [AllowAnonymous] public SecurityFunctionResultData FindMenuByUsername() { string username = service.UserId; diff --git a/CloudBuilder.Web.Entry/Controllers/Security/SecurityUserController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Security/SecurityUserController.auto.cs index 459adb0..f329c0f 100644 --- a/CloudBuilder.Web.Entry/Controllers/Security/SecurityUserController.auto.cs +++ b/CloudBuilder.Web.Entry/Controllers/Security/SecurityUserController.auto.cs @@ -214,7 +214,7 @@ this.securityUserService= securityUserService; } } - [PermissionOperate(name: "SecurityUser", operate: "None")] + [AllowAnonymous] [HttpPost] public dynamic FindMenuByUsername() {