根据LgbPricinpal方法更改,更改网站代码

This commit is contained in:
Argo-Lenovo 2017-03-23 16:21:23 +08:00
parent 6093b8f1ad
commit 630c9ec24d
11 changed files with 13 additions and 14 deletions

View File

@ -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 ? "成功!" : "失败" };
}

View File

@ -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();

View File

@ -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));

View File

@ -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 数据缓存");

View File

@ -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);

View File

@ -33,7 +33,7 @@
</div>
</form>
<div class="modal-footer">
<button id="btnSaveDisplayName" class="btn btn-default" type="button" disabled data-admin="@LgbPrincipal.IsAdmin(Model.UserName)"><i class="fa fa-save"></i><span>保存</span></button>
<button id="btnSaveDisplayName" class="btn btn-default" type="button" disabled data-admin="@LgbPrincipal.IsAdmin(User)"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>
@ -57,7 +57,7 @@
</div>
</form>
<div class="modal-footer">
<button id="btnSavePassword" class="btn btn-default" type="button" disabled data-admin="@LgbPrincipal.IsAdmin(Model.UserName)"><i class="fa fa-save"></i><span>保存</span></button>
<button id="btnSavePassword" class="btn btn-default" type="button" disabled data-admin="@LgbPrincipal.IsAdmin(User)"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>

View File

@ -63,7 +63,7 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">网站缓存<a id="clearCache" href="#" class="clearcache fa fa-times-circle-o" data-admin="@LgbPrincipal.IsAdmin(Model.UserName)" title="全部清除(WebAdmin可用)" role="tooltip" data-placement="left"></a><a id="refreshCache" href="#" class="pull-right fa fa-refresh" title="点击刷新" role="tooltip"></a></div>
<div class="panel-heading">网站缓存<a id="clearCache" href="#" class="clearcache fa fa-times-circle-o" data-admin="@LgbPrincipal.IsAdmin(User)" title="全部清除(WebAdmin可用)" role="tooltip" data-placement="left"></a><a id="refreshCache" href="#" class="pull-right fa fa-refresh" title="点击刷新" role="tooltip"></a></div>
<div class="panel-body">
<div class="tasks-widget">
<ul id="sortable" class="task-list ui-sortable"></ul>

View File

@ -4,7 +4,7 @@
<i class="fa fa-bars"></i>
<span id="websiteTitle">@Model.Title</span>
</a>
@if (LgbPrincipal.IsAdmin(User.Identity.Name) || User.IsInRole("Administrators"))
@if (LgbPrincipal.IsAdmin(User))
{
<ul class="notify-row">
<!-- tasks start -->

View File

@ -24,7 +24,7 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
public static IEnumerable<Menu> 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 =>
{

View File

@ -66,7 +66,7 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
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 =>
{

View File

@ -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