From 630c9ec24db92e5701b99c5007dcbb99cc9107c7 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Thu, 23 Mar 2017 16:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AELgbPricinpal=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=9B=B4=E6=94=B9=EF=BC=8C=E6=9B=B4=E6=94=B9=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Controllers/DictsController.cs | 2 +- Bootstrap.Admin/Controllers/HomeController.cs | 2 +- Bootstrap.Admin/Controllers/InfosController.cs | 4 ++-- Bootstrap.Admin/Controllers/LoginController.cs | 2 +- Bootstrap.Admin/Controllers/UsersController.cs | 3 +-- Bootstrap.Admin/Views/Admin/Infos.cshtml | 4 ++-- Bootstrap.Admin/Views/Admin/Profiles.cshtml | 2 +- Bootstrap.Admin/Views/Shared/Header.cshtml | 2 +- Bootstrap.DataAccess/MenuHelper.cs | 2 +- Bootstrap.DataAccess/UserHelper.cs | 2 +- DatabaseScripts/Procedures.sql | 2 +- 11 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Bootstrap.Admin/Controllers/DictsController.cs b/Bootstrap.Admin/Controllers/DictsController.cs index ddc8da59..6aca510a 100644 --- a/Bootstrap.Admin/Controllers/DictsController.cs +++ b/Bootstrap.Admin/Controllers/DictsController.cs @@ -73,7 +73,7 @@ namespace Bootstrap.Admin.Controllers [HttpDelete] public dynamic Delete([FromBody]string value) { - if (!LgbPrincipal.IsAdmin(User.Identity.Name) && !User.IsInRole("Administrators")) return new { result = false, msg = "当前用户权限不够" }; + if (!LgbPrincipal.IsAdmin(User)) return new { result = false, msg = "当前用户权限不够" }; var result = DictHelper.DeleteDict(value); return new { result = result, msg = result ? "成功!" : "失败" }; } diff --git a/Bootstrap.Admin/Controllers/HomeController.cs b/Bootstrap.Admin/Controllers/HomeController.cs index a05de20e..f6b5930d 100644 --- a/Bootstrap.Admin/Controllers/HomeController.cs +++ b/Bootstrap.Admin/Controllers/HomeController.cs @@ -50,7 +50,7 @@ namespace Bootstrap.Admin.Controllers var model = new LoginModel(); if (string.IsNullOrEmpty(userName)) return View(model); model.UserName = userName; - if (LgbPrincipal.IsAdmin(userName, password) || BootstrapUser.Authenticate(userName, password)) + if (LgbPrincipal.Authenticate(userName, password) || BootstrapUser.Authenticate(userName, password)) { FormsAuthentication.RedirectFromLoginPage(userName, remember == "true"); return new EmptyResult(); diff --git a/Bootstrap.Admin/Controllers/InfosController.cs b/Bootstrap.Admin/Controllers/InfosController.cs index 42482fe6..6eed095b 100644 --- a/Bootstrap.Admin/Controllers/InfosController.cs +++ b/Bootstrap.Admin/Controllers/InfosController.cs @@ -16,9 +16,9 @@ namespace Bootstrap.Admin.Controllers { var ret = string.Empty; var userName = User.Identity.Name; - if (LgbPrincipal.IsAdmin(userName)) userName = "default"; + if (LgbPrincipal.IsWebAdmin(userName)) userName = "default"; var files = HttpContext.Current.Request.Files; - if (files.Count > 0 && !LgbPrincipal.IsAdmin(userName)) + if (files.Count > 0) { var webSiteUrl = DictHelper.RetrieveIconFolderPath().Code; var fileName = string.Format("{0}{1}", userName, Path.GetExtension(files[0].FileName)); diff --git a/Bootstrap.Admin/Controllers/LoginController.cs b/Bootstrap.Admin/Controllers/LoginController.cs index c2e6f88e..59db2c19 100644 --- a/Bootstrap.Admin/Controllers/LoginController.cs +++ b/Bootstrap.Admin/Controllers/LoginController.cs @@ -34,7 +34,7 @@ namespace Bootstrap.Admin.Controllers dynamic user = value; string userName = user.userName; string password = user.password; - if (LgbPrincipal.IsAdmin(userName, password) || BootstrapUser.Authenticate(userName, password)) + if (LgbPrincipal.Authenticate(userName, password) || BootstrapUser.Authenticate(userName, password)) { var interval = int.Parse(Math.Round(FormsAuthentication.Timeout.TotalSeconds).ToString()); var token = CacheManager.AddOrUpdate(string.Format("WebApi-{0}", userName), interval, k => new LoginInfo() { UserName = userName, Token = Guid.NewGuid().ToString() }, (k, info) => info, "WebApi 数据缓存"); diff --git a/Bootstrap.Admin/Controllers/UsersController.cs b/Bootstrap.Admin/Controllers/UsersController.cs index 937b7219..2df7c950 100644 --- a/Bootstrap.Admin/Controllers/UsersController.cs +++ b/Bootstrap.Admin/Controllers/UsersController.cs @@ -37,8 +37,7 @@ namespace Bootstrap.Admin.Controllers return UserHelper.RetrieveUsersByName(value.UserName) == null; } var ret = false; - var userName = User.Identity.Name; - if (value.UserName.Equals(userName, System.StringComparison.OrdinalIgnoreCase) || LgbPrincipal.IsAdmin(userName)) + if (value.UserName.Equals(User.Identity.Name, System.StringComparison.OrdinalIgnoreCase) || LgbPrincipal.IsAdmin(User)) { if (value.UserStatus == 1) ret = UserHelper.SaveUserInfoByName(value); diff --git a/Bootstrap.Admin/Views/Admin/Infos.cshtml b/Bootstrap.Admin/Views/Admin/Infos.cshtml index 5c7dfede..fe089427 100644 --- a/Bootstrap.Admin/Views/Admin/Infos.cshtml +++ b/Bootstrap.Admin/Views/Admin/Infos.cshtml @@ -33,7 +33,7 @@ @@ -57,7 +57,7 @@ diff --git a/Bootstrap.Admin/Views/Admin/Profiles.cshtml b/Bootstrap.Admin/Views/Admin/Profiles.cshtml index 10e972dd..35778c53 100644 --- a/Bootstrap.Admin/Views/Admin/Profiles.cshtml +++ b/Bootstrap.Admin/Views/Admin/Profiles.cshtml @@ -63,7 +63,7 @@
-
网站缓存
+
网站缓存
    diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index c166ab0e..834e984d 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -4,7 +4,7 @@ @Model.Title - @if (LgbPrincipal.IsAdmin(User.Identity.Name) || User.IsInRole("Administrators")) + @if (LgbPrincipal.IsAdmin(User)) {
      diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs index 22914f0b..b38c5718 100644 --- a/Bootstrap.DataAccess/MenuHelper.cs +++ b/Bootstrap.DataAccess/MenuHelper.cs @@ -24,7 +24,7 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveMenus(string userName = null) { - userName = LgbPrincipal.IsAdmin(userName) ? string.Empty : userName; + userName = LgbPrincipal.IsWebAdmin(userName) ? string.Empty : userName; string key = string.Format("{0}-{1}", RetrieveMenusDataKey, userName); return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusDataKey), k => { diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index 9155fb9a..8cc05f5e 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -66,7 +66,7 @@ namespace Bootstrap.DataAccess /// public static User RetrieveUsersByName(string userName) { - if (LgbPrincipal.IsAdmin(userName)) return new User() { DisplayName = "网站管理员", UserName = userName, Icon = "~/Content/images/uploader/default.jpg" }; + if (LgbPrincipal.IsWebAdmin(userName)) return new User() { DisplayName = "网站管理员", UserName = userName, Icon = "~/Content/images/uploader/default.jpg" }; string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName); return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByNameDataKey), k => { diff --git a/DatabaseScripts/Procedures.sql b/DatabaseScripts/Procedures.sql index ad10fdf6..cc2e6eb2 100644 --- a/DatabaseScripts/Procedures.sql +++ b/DatabaseScripts/Procedures.sql @@ -128,7 +128,7 @@ BEGIN SET NOCOUNT ON; SET XACT_ABORT ON; -- Insert statements for procedure here - if @userName = '' or @userName is null + if @userName = '' or @userName is null or exists(select ur.ID from Users u inner join UserRole ur on u.ID = ur.UserID inner join Roles r on ur.RoleID = r.ID where r.RoleName = 'administrators' and u.UserName = @userName) select n.ID, n.ParentId, n.Name, n.[Order], n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.[Application], d.Name as CategoryName, ln.Name as ParentName from Navigations n inner join Dicts d on n.Category = d.Code and d.Category = N'菜单' and d.Define = 0 left join Navigations ln on n.ParentId = ln.ID