mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add group support to partial permissions
This commit is contained in:
parent
c26a95ed60
commit
cee7ca2ca0
@ -42,7 +42,7 @@ namespace Kyoo.Abstractions.Models.Permissions
|
||||
/// <summary>
|
||||
/// The group of this permission.
|
||||
/// </summary>
|
||||
public Group? Group { get; set; }
|
||||
public Group Group { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ask a permission to run an action.
|
||||
|
@ -54,6 +54,11 @@ namespace Kyoo.Abstractions.Models.Permissions
|
||||
/// </summary>
|
||||
public enum Group
|
||||
{
|
||||
/// <summary>
|
||||
/// Default group indicating no value.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Allow all operations on basic items types.
|
||||
/// </summary>
|
||||
|
@ -93,7 +93,7 @@ namespace Kyoo.Authentication
|
||||
/// <summary>
|
||||
/// The group of he permission.
|
||||
/// </summary>
|
||||
private readonly Group _group = Group.Overall;
|
||||
private Group _group;
|
||||
|
||||
/// <summary>
|
||||
/// The permissions options to retrieve default permissions.
|
||||
@ -146,7 +146,7 @@ namespace Kyoo.Authentication
|
||||
);
|
||||
}
|
||||
|
||||
if (group != null)
|
||||
if (group is not null and not Group.None)
|
||||
_group = group.Value;
|
||||
_options = options;
|
||||
}
|
||||
@ -159,6 +159,16 @@ namespace Kyoo.Authentication
|
||||
|
||||
if (permission == null || kind == null)
|
||||
{
|
||||
if (
|
||||
context.HttpContext.Items["PermissionGroup"]
|
||||
is Group group and not Group.None
|
||||
)
|
||||
_group = group;
|
||||
else if (_group == Group.None)
|
||||
_group = Group.Overall;
|
||||
else
|
||||
context.HttpContext.Items["PermissionGroup"] = _group;
|
||||
|
||||
switch (context.HttpContext.Items["PermissionType"])
|
||||
{
|
||||
case string perm:
|
||||
|
Loading…
x
Reference in New Issue
Block a user