public Role ForApp(string app, bool isFrontend = false) { Guard.NotNullOrEmpty(app, nameof(app)); var result = new HashSet <Permission>(); if (Permissions.Any()) { var prefix = P.ForApp(P.App, app).Id; foreach (var permission in Permissions) { result.Add(new Permission(string.Concat(prefix, ".", permission.Id))); } } if (isFrontend) { foreach (var extraPermissionId in ExtraPermissions) { var extraPermission = P.ForApp(extraPermissionId, app); result.Add(extraPermission); } } return(new Role(Name, new PermissionSet(result), Properties)); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var permissions = await _sessionManager.GetPermissions(); if (permissions == null) { output.SuppressOutput(); } // permission if (!string.IsNullOrEmpty(Permission) && !permissions.Select(p => p.Key).Contains(Permission)) { output.SuppressOutput(); } // list of permissions if (Permissions.Any() && !permissions.Select(p => p.Key).Any(p => Permissions.Contains(p))) { output.SuppressOutput(); } // permission group if (!string.IsNullOrEmpty(PermissionGroup) && !permissions.Any(p => p.Group_Name.Equals(PermissionGroup))) { output.SuppressOutput(); } }
/// <summary> /// 判断当前用户是否拥有指定的权限,全字匹配 /// </summary> /// <param name="permission"></param> /// <returns></returns> protected bool HasPermissionFullWord(string permission) { if (Permissions.Any(p => p.MOD_URL.ToUpper().Trim() == permission.ToUpper().Trim())) { return(true); } return(false); }
public bool IsHavePermission(RightView permission) { if (Permissions.Any(r => (permission.ControllerName == r.ControllerName) && (permission.ActionName == r.ActionName))) { return(true); } return(false); }
public void AddPermission(string permission) { if (Permissions.Any(p => string.Equals(p, permission, StringComparison.CurrentCultureIgnoreCase))) { return; } Permissions.Add(permission); }
public bool IsInPermission(string permission) { if (Permissions.Any(p => p.Contains(permission))) { return(true); } return(false); }
private bool Check(Dictionary <string, string> map, string key) { var shortcut = map.GetValueOrDefault(key); if (shortcut == null) { return(true); } return(Permissions.Any(p => p.Name.Match(shortcut))); }
/// <summary> Checks whether this command may be called by players of a given rank. </summary> public bool CanBeCalledBy([NotNull] Rank rank) { if (rank == null) { throw new ArgumentNullException("rank"); } return(Permissions == null || Permissions.All(rank.Can) || AnyPermission && Permissions.Any(rank.Can)); }
/// <summary> /// Checks whether the user has permission. /// </summary> /// <param name="product">Name of the product</param> /// <param name="permissionValue">Permission value</param> /// <returns>bool if has permission</returns> public bool HasPermission(string product, string permissionValue) { if (Permissions == null || !Permissions.Any()) { return(false); } return(Permissions.Any(x => x.Key.StartsWith(product, StringComparison.OrdinalIgnoreCase) && x.Value.Any(y => y.Equals(permissionValue, StringComparison.OrdinalIgnoreCase)))); }
public void AddPermission(IEnumerable <string> permissions) { foreach (var permission in permissions) { if (Permissions.Any(p => string.Equals(p, permission, StringComparison.CurrentCultureIgnoreCase))) { continue; } Permissions.Add(permission); } }
public bool HasPermission(string permission) { if (Permissions.Any(r => permission.Contains(r))) { return(true); } else { return(false); } }
public bool HavingRight(string permissionCode) { if (IsRoot.Equals(1)) { return(true); } if (Permissions.Any(p => p.Contains(permissionCode))) { return(true); } return(false); }
public virtual bool HasPermission(string permission) { #if NETFRAMEWORK using (new Profiler(nameof(ApplicationUser), Profiling.AppDevSymbolType.ClassOperation, nameof(ApplicationUser.HasPermission))) { bool hasPermissionfromRoles = (Roles?.Any((rr) => rr.Permissions.Any((pp) => pp.Name == permission)) ?? false); return(hasPermissionfromRoles || (Permissions?.Any((pp) => pp.Name == permission) ?? false)); } #else bool hasPermissionfromRoles = (Roles?.Any((rr) => rr.Permissions.Any((pp) => pp.Name == permission)) ?? false); return(hasPermissionfromRoles || (Permissions?.Any((pp) => pp.Name == permission) ?? false)); #endif }
/// <summary> Checks whether this command may be called by players of a given rank. </summary> public bool CanBeCalledBy([NotNull] Rank rank, bool isConsole) { if (rank == null && !isConsole) { throw new ArgumentNullException("rank"); } if (isConsole) { return(true); } return(Permissions == null || Permissions.All(rank.Can) || AnyPermission && Permissions.Any(rank.Can)); }
public bool IsPermissionInRole(string permission) { var retVal = false; try { if (Permissions.Any(perm => perm.Name == permission)) { retVal = true; } } catch (Exception) { } return(retVal); }
public bool IsPermissionInRole(PermissionType permission) { var retVal = false; try { if (Permissions.Any(perm => (int)perm.Type == (int)permission)) { retVal = true; } } catch (Exception) { } return(retVal); }
protected override void OnLoad(EventArgs e) { string url = PageUrl.ToUpper().Trim(); if (_IsAuthenticate) { string rawUrl = PageRawUrl.ToUpper().Trim(); if (!Permissions.Any(p => p.MOD_URL.ToUpper().Trim() == url || p.MOD_URL.ToUpper().Trim() == rawUrl)) { b_MissingParameter("无权访问该页面."); } } base.OnLoad(e); }
/// <summary> /// 判断当前用户是否拥有指定的权限 /// </summary> /// <param name="permission">权限名称</param> /// <returns></returns> protected bool HasPermission(string permission) { string url = Regex.Replace(PageUrl, "List.aspx", permission + ".aspx", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace).ToUpper().Trim(); if (Permissions.Any(p => p.MOD_URL.ToUpper() == (PageUrl + "?" + permission).ToUpper())) { return(true); } else if (Permissions.Any(p => p.MOD_URL.ToUpper().Trim() == url)) { return(true); } else if (Permissions.Any(p => p.MOD_URL == permission)) { return(true); } return(false); }
/// <summary> /// 获取拥有授权的模块列表 /// </summary> public List <Module> GetAuthorizedModules() { var modules = PlatformCaches.GetCachesByType("Modules"); Modules = modules.Select(obj => (Module)obj.CacheItem) .Where(item => item.DomainId == Domain.Id) .OrderBy(obj => obj.ModuleIndex) .ToList(); if (!WdUser.IsInRole("Root") && !WdUser.IsInRole("SuperAdmin")) { Modules = Modules .Where(item => Permissions.Any(per => per.Id == item.PermissionId)) .OrderBy(obj => obj.ModuleIndex) .ToList(); } return(Modules); }
public Role ForApp(string app) { var result = new HashSet <Permission> { P.ForApp(P.AppCommon, app) }; if (Permissions.Any()) { var prefix = P.ForApp(P.App, app).Id; foreach (var permission in Permissions) { result.Add(new Permission(string.Concat(prefix, ".", permission.Id))); } } return(new Role(Name, new PermissionSet(result))); }
public bool HasPermission(string controllerName, string actionName) { bool isValid = false; var urlApi = controllerName + "_" + actionName; if (UserType == 10 || urlApi.Equals("Home_Permission") || urlApi.Equals("Home_SystemLocked") || urlApi.Equals("Language_Translation") || urlApi.Equals("Home_Logout")) { isValid = true; } else { if (Permissions.Count > 0 && !string.IsNullOrEmpty(urlApi)) { isValid = Permissions.Any(x => x.ResourceCode != null && x.ResourceCode.ToLower().Equals(urlApi.ToLower())); } } return(isValid); }
public IRole <RoleClaim> AddPermission(string name, string identifier) { if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(identifier)) { throw new ArgumentNullException("permission"); } if (Permissions == null) { Permissions = new List <RoleClaim>(); } if (!Permissions.Any(x => x.Identifier == identifier)) { Permissions.Add(new RoleClaim() { ClaimType = identifier, ClaimValue = name }); } return(this); }
/// <summary> /// Checkes Persmission for autherized user and throws out of the management system if persmision is not granted /// </summary> public void CheckPermission(string Permission) { if (IsAuthenticated) { if (IsAdmin || string.IsNullOrEmpty(Permission) || (Permissions != null && Permissions.Any(p => (p.AspxPagePath == Permission || p.PermissionCode == Permission)))) { return; } } HttpContext.Current.Response.Redirect("~/"); }
public bool HasPermission(string permissionCode) { return(Permissions.Any(t => t.Code.Equals(permissionCode, StringComparison.OrdinalIgnoreCase))); }
public bool HasPermission(PermissionEnum perm) { return(Permissions.Any(p => p.Id == (int)perm)); }
/// <summary> /// Checkes Persmission for autherized user and returns wether user is granted to this permission or not /// </summary> public bool IsGranted(string Permission) { if (IsAuthenticated) { if (IsAdmin || string.IsNullOrEmpty(Permission) || (Permissions != null && Permissions.Any(p => (p.AspxPagePath == Permission || p.PermissionCode == Permission)))) { return(true); } } return(false); }
/// <summary> /// Return true if is allowed /// </summary> /// <param name="manifest">Manifest</param> /// <param name="method">Method</param> /// <returns>Return true or false</returns> public bool CanCall(ContractManifest manifest, string method) { return(Permissions.Any(u => u.IsAllowed(manifest, method))); }
/// <summary> /// Check if user has permission /// </summary> /// <param name="permission"></param> /// <returns></returns> public bool HasPermission(string permission) { Expect.IsNotBlank(permission, nameof(permission)); return(Permissions.Any(p => p.EqualsNoCase(permission))); }
public bool ShouldMapSerialNumber() => IsNew() || !IsActive || !Password.IsEmpty() || Roles.Any(a => a.IsNew() || a.IsDeleted()) || IgnoredPermissions.Any(p => p.IsDeleted() || p.IsNew()) || Permissions.Any(p => p.IsDeleted() || p.IsNew());
public bool ShouldResetSecurityToken() => IsNew() || !IsActive || !Password.IsEmpty() || Roles.Any(a => a.IsNew() || a.IsDeleted()) || IgnoredPermissions.Any(p => p.IsDeleted() || p.IsNew()) || Permissions.Any(p => p.IsDeleted() || p.IsNew());