private void BindPermissions() { GlobalPermission perm = new GlobalPermission(GlobalRights.ManagePermissions); PermissionSet1.Enabled = perm.CheckDemand(); PermissionSet1.DataSource = new object[] { GlobalPermissions.Instance }; PermissionSet1.DataBind(); }
public async void GrantedGlobalPermissionReturnsTrueForGrantedLocalWithDifferingTarget() { var requiredPermission = (Permission.SetClass, PermissionTarget.Self); var grantedLocalPermission = new LocalPermission { Permission = Permission.SetClass, Target = PermissionTarget.Self, ServerDiscordID = (long)this.Guild.Id, UserDiscordID = (long)this.User.Id }; var grantedGlobalPermission = new GlobalPermission { Permission = Permission.SetClass, Target = PermissionTarget.Other, UserDiscordID = (long)this.User.Id }; await this.Database.GlobalPermissions.AddAsync(grantedGlobalPermission); await this.Database.LocalPermissions.AddAsync(grantedLocalPermission); await this.Database.SaveChangesAsync(); Assert.True(await this.Permissions.HasPermissionAsync(this.Database, this.Guild, this.User, requiredPermission)); }
/// <summary> /// Adds a mocked global permission to the database. /// </summary> /// <param name="globalPermission">The permission to add.</param> public void AddMockedGlobalPermission([NotNull] GlobalPermission globalPermission) { using (var db = GetDatabaseContext()) { db.GlobalPermissions.Add(globalPermission); db.SaveChanges(); } }
protected void Page_Load(object sender, EventArgs e) { GlobalPermission perm = new GlobalPermission(GlobalRights.ManageFiles); if (!perm.CheckDemand()) { this.tabStripItems.Tabs[2].Visible = false; this.pageViewFiles.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { GlobalPermission perm = new GlobalPermission(GlobalRights.ManageFiles); if (!perm.CheckDemand()) { this.tabStripItems.Tabs[1].Visible = false; this.pageViewFiles.Visible = false; } }
public ResourceRequest(string user, Data.ResourceId id, GlobalPermission globalPermissions, ResourcePermission resourcePermissions) : base(user, id.ToString(), globalPermissions, resourcePermissions) { }
public GlobalRequest(string user, GlobalPermission globalPermissions, ResourcePermission resourcePermissions) : base(user, GLOBAL_FILE_ID, globalPermissions, resourcePermissions) { }
public Request(string user, string id, GlobalPermission globalPermissions, ResourcePermission resourcePermissions) : this(user, id, new Permissions(globalPermissions, resourcePermissions)) { }
public Permissions(GlobalPermission global, ResourcePermission resource) { Global = global; Resource = resource; }
public AdministerGlobalPermission(GlobalPermission permission) { Permission = permission; }