mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Adds authorization permissions administrator dashboard
This commit is contained in:
1 parent
152cb48050
commit
583b8db865
106 files changed
+5916
-2085
No files matched your search
+2
-2
@@ -19,9 +19,9 @@ public class UserAuthorizationEntity
|
||||
public required Guid UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of roles associated to the user.
|
||||
/// Gets the role associated to the user.
|
||||
/// </summary>
|
||||
public required IReadOnlySet<string> Roles { get; init; }
|
||||
public required string? Role { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of permissions associated to the user.
|
||||
|
||||
@@ -51,9 +51,9 @@ public class UserEntity : IStorageEntity, IAuditableEntity
|
||||
public required ICollection<LibraryEntity> Libraries { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of user roles associations that include this user.
|
||||
/// Gets the user roles association that includes this user.
|
||||
/// </summary>
|
||||
public required ICollection<UserRoleEntity> UserRoles { get; init; } = [];
|
||||
public required UserRoleEntity? UserRole { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of user permission associations that include this user.
|
||||
|
||||
@@ -25,5 +25,7 @@ public static partial class Errors
|
||||
public static Error PermissionIdCannotBeEmpty => Error.Validation(description: nameof(PermissionIdCannotBeEmpty));
|
||||
public static Error RoleNameCannotBeEmpty => Error.Validation(description: nameof(RoleNameCannotBeEmpty));
|
||||
public static Error RoleNameCannotBeNull => Error.Validation(description: nameof(RoleNameCannotBeNull));
|
||||
public static Error CannotRemoveLastAdmin => Error.Forbidden(description: nameof(CannotRemoveLastAdmin));
|
||||
public static Error UserMustHaveRoleOrDirectPermissions => Error.Forbidden(description: nameof(UserMustHaveRoleOrDirectPermissions));
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserPermissions;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetUserPermissionsRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetUserPermissionsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetUserPermissionsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetUserPermissionsQuery ToQuery(this GetUserPermissionsRequest request)
|
||||
{
|
||||
return new GetUserPermissionsQuery(
|
||||
request.UserId
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserRole;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetUserRoleRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetUserRoleRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetUserRoleQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetUserRoleQuery ToQuery(this GetUserRoleRequest request)
|
||||
{
|
||||
return new GetUserRoleQuery(
|
||||
request.UserId
|
||||
);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateUserRoleAndPermissionsRequest"/>.
|
||||
/// </summary>
|
||||
public static class UpdateUserRoleAndPermissionsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateUserRoleAndPermissionsCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static UpdateUserRoleAndPermissionsCommand ToCommand(this UpdateUserRoleAndPermissionsRequest request)
|
||||
{
|
||||
return new UpdateUserRoleAndPermissionsCommand(
|
||||
request.UserId!.Value,
|
||||
request.RoleId,
|
||||
request.Permissions!
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@ public static class UserAuthorizationEntityMapping
|
||||
{
|
||||
return new AuthorizationResponse(
|
||||
repositoryEntity.UserId,
|
||||
repositoryEntity.Roles,
|
||||
repositoryEntity.Role,
|
||||
repositoryEntity.Permissions
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user