Adds authorization roles administrator dashboard

This commit is contained in:
BinaryAlley committed 2024-12-18 13:12:42 +02:00
1 parent 290af03c83
commit 1df31515fb
191 files changed
+6189 -806

No files matched your search

@@ -24,11 +24,6 @@ public class PermissionEntity : IStorageEntity, IAuditableEntity
/// </summary>
public required AuthorizationPermission PermissionName { get; init; }
/// <summary>
/// Gets the description of the permission.
/// </summary>
public string? PermissionDescription { get; set; }
/// <summary>
/// Gets or sets the collection of role permission associations that include this permission.
/// </summary>
@@ -42,12 +37,12 @@ public class PermissionEntity : IStorageEntity, IAuditableEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
@@ -12,7 +12,7 @@ namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
/// Repository entity for a permission in the authorization system.
/// </summary>
[DebuggerDisplay("RoleName: {RoleName}")]
public class RoleEntity : IStorageEntity
public class RoleEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets the Id of the role.
@@ -22,12 +22,7 @@ public class RoleEntity : IStorageEntity
/// <summary>
/// Gets the name of the role.
/// </summary>
public required AuthorizationRole RoleName { get; init; }
/// <summary>
/// Gets or sets the description of the role.
/// </summary>
public string? RoleDescription { get; set; }
public required string RoleName { get; init; }
/// <summary>
/// Gets or sets the collection of user roles associations that include this role.
@@ -42,12 +37,12 @@ public class RoleEntity : IStorageEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
@@ -40,12 +40,12 @@ public class RolePermissionEntity : IStorageEntity, IAuditableEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
@@ -8,7 +8,7 @@ using System.Diagnostics;
namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
/// <summary>
/// Data Transfer object containing all the authorization info of a user.
/// Data Transfer Object containing all the authorization info of a user.
/// </summary>
[DebuggerDisplay("UserId: {UserId}")]
public class UserAuthorizationEntity
@@ -21,7 +21,7 @@ public class UserAuthorizationEntity
/// <summary>
/// Gets the collection of roles associated to the user.
/// </summary>
public required IReadOnlySet<AuthorizationRole> Roles { get; init; }
public required IReadOnlySet<string> Roles { get; init; }
/// <summary>
/// Gets the collection of permissions associated to the user.
@@ -41,12 +41,12 @@ public class UserPermissionEntity : IStorageEntity, IAuditableEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
@@ -41,12 +41,12 @@ public class UserRoleEntity : IStorageEntity, IAuditableEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
@@ -63,12 +63,12 @@ public class UserEntity : IStorageEntity, IAuditableEntity
/// <summary>
/// Gets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets the optional time and date when the entity was updated.
@@ -1,7 +1,12 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Authorization;
@@ -13,4 +18,11 @@ public interface IPermissionRepository : IRepository<PermissionEntity>,
IInsertRepositoryAction<PermissionEntity>,
IGetAllRepositoryAction<PermissionEntity>
{
/// <summary>
/// Gets all permissions that have their Id match an Id in <paramref name="ids"/> from the storage medium.
/// </summary>
/// <param name="ids">The list of Ids of the permissions to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of <see cref="PermissionEntity"/>, or an error.</returns>
Task<ErrorOr<IEnumerable<PermissionEntity>>> GetByIdsAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken);
}
@@ -3,7 +3,7 @@ using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using Lumina.Domain.Common.Enums.Authorization;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -14,8 +14,11 @@ namespace Lumina.Application.Common.DataAccess.Repositories.Authorization;
/// Interface for the repository for authorization roles.
/// </summary>
public interface IRoleRepository : IRepository<RoleEntity>,
IGetByIdRepositoryAction<RoleEntity, Guid>,
IGetAllRepositoryAction<RoleEntity>,
IInsertRepositoryAction<RoleEntity>,
IGetAllRepositoryAction<RoleEntity>
IUpdateRepositoryAction<RoleEntity>,
IDeleteByIdRepositoryAction<Guid>
{
/// <summary>
/// Gets a role identified by <paramref name="roleType"/> from the repository, if it exists.
@@ -23,5 +26,5 @@ public interface IRoleRepository : IRepository<RoleEntity>,
/// <param name="roleType">The type of role to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a <see cref="RoleEntity"/> if found, or an error.</returns>
Task<ErrorOr<RoleEntity?>> GetByNameAsync(AuthorizationRole roleType, CancellationToken cancellationToken);
Task<ErrorOr<RoleEntity?>> GetByNameAsync(string roleType, CancellationToken cancellationToken);
}