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));
            }
예제 #3
0
    private void BindPermissions()
    {
        GlobalPermission perm = new GlobalPermission(GlobalRights.ManagePermissions);

        PermissionSet1.Enabled    = perm.CheckDemand();
        PermissionSet1.DataSource = new object[] { GlobalPermissions.Instance };
        PermissionSet1.DataBind();
    }
 /// <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;
     }
 }
예제 #6
0
    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)
 {
 }
예제 #9
0
 public GlobalRequest(string user, GlobalPermission globalPermissions, ResourcePermission resourcePermissions)
     : base(user, GLOBAL_FILE_ID, globalPermissions, resourcePermissions)
 {
 }
예제 #10
0
 public Request(string user, string id, GlobalPermission globalPermissions, ResourcePermission resourcePermissions)
     : this(user, id, new Permissions(globalPermissions, resourcePermissions))
 {
 }
예제 #11
0
 public Permissions(GlobalPermission global, ResourcePermission resource)
 {
     Global   = global;
     Resource = resource;
 }
예제 #12
0
 public ResourceRequest(string user, Data.ResourceId id, GlobalPermission globalPermissions, ResourcePermission resourcePermissions)
     : base(user, id.ToString(), globalPermissions, resourcePermissions)
 {
 }
예제 #13
0
 public Permissions(GlobalPermission global, ResourcePermission resource)
 {
     Global = global;
     Resource = resource;
 }
예제 #14
0
 public Request(string user, string id, GlobalPermission globalPermissions, ResourcePermission resourcePermissions)
     : this(user, id, new Permissions(globalPermissions, resourcePermissions))
 {
 }
 public AdministerGlobalPermission(GlobalPermission permission)
 {
     Permission = permission;
 }