Adds authorization module tests

This commit is contained in:
BinaryAlley committed 2025-01-01 22:56:07 +02:00
1 parent 718e1c49cf
commit 0114ff13e8
125 files changed
+10411 -203

No files matched your search

@@ -13,7 +13,7 @@ namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
/// Repository entity for a media library.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class LibraryEntity : IStorageEntity
public class LibraryEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets the Id of the media library.
@@ -48,10 +48,20 @@ public class LibraryEntity : IStorageEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime Created { get; set; }
public required DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the optional Id of the user that updated the entity.
/// </summary>
public required Guid? UpdatedBy { get; set; }
}
@@ -12,7 +12,7 @@ namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenCont
/// Repository entity for a book.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class BookEntity : IStorageEntity
public class BookEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets the Id of the media item.
@@ -198,10 +198,20 @@ public class BookEntity : IStorageEntity
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime Created { get; set; }
public required DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the optional Id of the user that updated the entity.
/// </summary>
public required Guid? UpdatedBy { get; set; }
}
@@ -24,8 +24,8 @@ public static class LibraryEntityMapping
repositoryEntity.Title,
repositoryEntity.LibraryType,
repositoryEntity.ContentLocations.Select(location => location.Path).ToList(),
repositoryEntity.Created,
repositoryEntity.Updated
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
}
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Linq;
#endregion
@@ -25,8 +26,10 @@ public static class LibraryMapping
LibraryType = domainEntity.LibraryType,
UserId = domainEntity.UserId.Value,
ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(),
Created = domainEntity.Created,
Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.Empty,
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
UpdatedBy = Guid.Empty
};
}
}
@@ -124,8 +124,8 @@ public static class BookEntityMapping
Optional<string>.FromNullable(repositoryEntity.GoogleBooksId),
Optional<string>.FromNullable(repositoryEntity.BarnesAndNobleId),
Optional<string>.FromNullable(repositoryEntity.AppleBooksId),
repositoryEntity.Created,
Optional<DateTime>.FromNullable(repositoryEntity.Updated),
repositoryEntity.CreatedOnUtc,
Optional<DateTime>.FromNullable(repositoryEntity.UpdatedOnUtc),
isbnsResult.Select(isbn => isbn.Value).ToList(),
[],
bookRatingsResult.Select(bookRating => bookRating.Value).ToList());
@@ -207,8 +207,8 @@ public static class BookEntityMapping
[.. repositoryEntity.ISBNs.ToResponses()],
null,
[.. repositoryEntity.Ratings.ToResponses()],
repositoryEntity.Created,
repositoryEntity.Updated
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
}
@@ -3,6 +3,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentL
using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using System;
using System.Linq;
#endregion
@@ -56,8 +57,10 @@ public static class BookMapping
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
ISBNs = domainEntity.ISBNs.ToRepositoryEntities().ToList(),
Ratings = domainEntity.Ratings.ToRepositoryEntities().ToList(),
Created = domainEntity.Created,
Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
UpdatedBy = domainEntity.UpdatedOnUtc.HasValue ? Guid.NewGuid() : null,
};
}
}
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using System;
using System.Linq;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
#endregion
@@ -15,8 +15,8 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
/// <param name="Title">The title of the media library.</param>
/// <param name="LibraryType">The type of the media library.</param>
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located.</param>
/// <param name="Created">The date and time when the library was created.</param>
/// <param name="Updated">The optional date and time when the library was updated.</param>
/// <param name="CreatedOnUtc">The date and time when the library was created.</param>
/// <param name="UpdatedOnUtc">The optional date and time when the library was updated.</param>
[DebuggerDisplay("Title: {Title}")]
public record LibraryResponse(
Guid Id,
@@ -24,6 +24,6 @@ public record LibraryResponse(
string Title,
LibraryType LibraryType,
List<string> ContentLocations,
DateTime Created,
DateTime? Updated
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
@@ -31,8 +31,8 @@ namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibr
/// <param name="ISBNs">The list of ISBN (International Standard Book Number) of the book.</param>
/// <param name="Contributors">The list of media contributors (actors, directors, etc) starring in this book.</param>
/// <param name="Ratings">The list of ratings for this book.</param>
/// <param name="Created">The date and time when the book was created.</param>
/// <param name="Updated">The optional date and time when the book was updated.</param>
/// <param name="CreatedOnUtc">The date and time when the book was created.</param>
/// <param name="UpdatedOnUtc">The optional date and time when the book was updated.</param>
[DebuggerDisplay("Title: {Metadata.Title}")]
public record BookResponse(
Guid Id,
@@ -53,6 +53,6 @@ public record BookResponse(
List<IsbnDto>? ISBNs,
List<MediaContributorDto>? Contributors,
List<BookRatingDto>? Ratings,
DateTime Created,
DateTime? Updated
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
@@ -10,12 +10,12 @@ namespace Lumina.Contracts.Responses.UsersManagement.Users;
/// </summary>
/// <param name="Id">The id of the user.</param>
/// <param name="Username">The username of the user.</param>
/// <param name="Created">The date and time when the user was created.</param>
/// <param name="Updated">The optional date and time when the user was updated.</param>
/// <param name="CreatedOnUtc">The date and time when the user was created.</param>
/// <param name="UpdatedOnUtc">The optional date and time when the user was updated.</param>
[DebuggerDisplay("Username: {Username}")]
public record UserResponse(
Guid Id,
string Username,
DateTime Created,
DateTime? Updated
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
@@ -130,9 +130,9 @@ public class BookConfiguration : IEntityTypeConfiguration<BookEntity>
.HasColumnOrder(28);
builder.Property(book => book.AppleBooksId)
.HasColumnOrder(29);
builder.Property(book => book.Created)
builder.Property(book => book.CreatedOnUtc)
.HasColumnOrder(30);
builder.Property(book => book.Updated)
builder.Property(book => book.UpdatedOnUtc)
.HasColumnOrder(31);
//builder.HasMany<ContributorIdModel>()
@@ -0,0 +1,709 @@
// <auto-generated />
using System;
using Lumina.DataAccess.Core.UoW;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
[DbContext(typeof(LuminaDbContext))]
[Migration("20241227113945_ImplementsAuditColumns")]
partial class ImplementsAuditColumns
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
modelBuilder.Entity("BookGenres", b =>
{
b.Property<Guid>("BookId")
.HasColumnType("TEXT");
b.Property<string>("GenreId")
.HasColumnType("TEXT");
b.HasKey("BookId", "GenreId");
b.HasIndex("GenreId");
b.ToTable("BookGenres", (string)null);
});
modelBuilder.Entity("BookTags", b =>
{
b.Property<Guid>("BookId")
.HasColumnType("TEXT");
b.Property<string>("TagId")
.HasColumnType("TEXT");
b.HasKey("BookId", "TagId");
b.HasIndex("TagId");
b.ToTable("BookTags", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.Property<string>("PermissionName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.HasKey("Id");
b.ToTable("Permissions", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.Property<string>("RoleName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.HasKey("Id");
b.ToTable("Roles", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
{
b.Property<Guid>("RoleId")
.HasColumnType("TEXT");
b.Property<Guid>("PermissionId")
.HasColumnType("TEXT");
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.HasKey("RoleId", "PermissionId");
b.HasIndex("PermissionId");
b.HasIndex("RoleId", "PermissionId")
.IsUnique();
b.ToTable("RolePermissions", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("TEXT");
b.Property<Guid>("PermissionId")
.HasColumnType("TEXT");
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.HasKey("UserId", "PermissionId");
b.HasIndex("PermissionId");
b.HasIndex("UserId", "PermissionId")
.IsUnique();
b.ToTable("UserPermissions", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("TEXT");
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid>("RoleId")
.HasColumnType("TEXT");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.HasKey("UserId");
b.HasIndex("RoleId");
b.HasIndex("UserId", "RoleId")
.IsUnique();
b.ToTable("UserRoles", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Genres", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Tags", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT");
b.Property<string>("LibraryType")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT");
b.Property<Guid>("UserId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Libraries", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<string>("ASIN")
.HasMaxLength(10)
.HasColumnType("TEXT")
.HasColumnOrder(21);
b.Property<string>("AppleBooksId")
.HasColumnType("TEXT")
.HasColumnOrder(29);
b.Property<string>("BarnesAndNobleId")
.HasMaxLength(10)
.HasColumnType("TEXT")
.HasColumnOrder(28);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(30);
b.Property<string>("Description")
.HasMaxLength(2000)
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.Property<string>("Edition")
.HasMaxLength(50)
.HasColumnType("TEXT")
.HasColumnOrder(19);
b.Property<string>("Format")
.HasColumnType("TEXT")
.HasColumnOrder(18);
b.Property<string>("GoodreadsId")
.HasColumnType("TEXT")
.HasColumnOrder(22);
b.Property<string>("GoogleBooksId")
.HasMaxLength(12)
.HasColumnType("TEXT")
.HasColumnOrder(27);
b.Property<string>("LCCN")
.HasColumnType("TEXT")
.HasColumnOrder(23);
b.Property<string>("LanguageCode")
.HasColumnType("TEXT")
.HasColumnOrder(10);
b.Property<string>("LanguageName")
.HasColumnType("TEXT")
.HasColumnOrder(11);
b.Property<string>("LanguageNativeName")
.HasColumnType("TEXT")
.HasColumnOrder(12);
b.Property<string>("LibraryThingId")
.HasMaxLength(50)
.HasColumnType("TEXT")
.HasColumnOrder(26);
b.Property<string>("OCLCNumber")
.HasColumnType("TEXT")
.HasColumnOrder(24);
b.Property<string>("OpenLibraryId")
.HasMaxLength(50)
.HasColumnType("TEXT")
.HasColumnOrder(25);
b.Property<string>("OriginalLanguageCode")
.HasColumnType("TEXT")
.HasColumnOrder(13);
b.Property<string>("OriginalLanguageName")
.HasColumnType("TEXT")
.HasColumnOrder(14);
b.Property<string>("OriginalLanguageNativeName")
.HasColumnType("TEXT")
.HasColumnOrder(15);
b.Property<DateOnly?>("OriginalReleaseDate")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<int?>("OriginalReleaseYear")
.HasColumnType("INTEGER")
.HasColumnOrder(5);
b.Property<string>("OriginalTitle")
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<int?>("PageCount")
.HasColumnType("INTEGER")
.HasColumnOrder(17);
b.Property<string>("Publisher")
.HasMaxLength(100)
.HasColumnType("TEXT")
.HasColumnOrder(16);
b.Property<DateOnly?>("ReReleaseDate")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<int?>("ReReleaseYear")
.HasColumnType("INTEGER")
.HasColumnOrder(7);
b.Property<string>("ReleaseCountry")
.HasColumnType("TEXT")
.HasColumnOrder(8);
b.Property<string>("ReleaseVersion")
.HasColumnType("TEXT")
.HasColumnOrder(9);
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(31);
b.Property<int?>("VolumeNumber")
.HasColumnType("INTEGER")
.HasColumnOrder(20);
b.HasKey("Id");
b.ToTable("Books", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(7);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<string>("TempPassword")
.HasColumnType("TEXT")
.HasColumnOrder(3);
b.Property<DateTime?>("TempPasswordCreated")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.Property<string>("TotpSecret")
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(9);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(8);
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.HasKey("Id");
b.HasIndex("Username")
.IsUnique();
b.ToTable("Users", (string)null);
});
modelBuilder.Entity("BookGenres", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
.WithMany()
.HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null)
.WithMany()
.HasForeignKey("GenreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("BookTags", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
.WithMany()
.HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null)
.WithMany()
.HasForeignKey("TagId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
.WithMany("RolePermissions")
.HasForeignKey("PermissionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
.WithMany("RolePermissions")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Permission");
b.Navigation("Role");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
.WithMany("UserPermissions")
.HasForeignKey("PermissionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
.WithMany("UserPermissions")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Permission");
b.Navigation("User");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
.WithOne("UserRole")
.HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
{
b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
.WithMany("Libraries")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 =>
{
b1.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b1.Property<Guid>("LibraryId")
.HasColumnType("TEXT");
b1.Property<string>("Path")
.IsRequired()
.HasMaxLength(260)
.HasColumnType("TEXT")
.HasColumnName("Path");
b1.HasKey("Id");
b1.HasIndex("LibraryId");
b1.ToTable("LibraryContentLocations", (string)null);
b1.WithOwner()
.HasForeignKey("LibraryId");
});
b.Navigation("ContentLocations");
b.Navigation("User");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
{
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 =>
{
b1.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b1.Property<Guid>("BookId")
.HasColumnType("TEXT");
b1.Property<decimal>("MaxValue")
.HasColumnType("decimal(3,2)");
b1.Property<string>("Source")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b1.Property<decimal>("Value")
.HasColumnType("decimal(3,2)");
b1.Property<int?>("VoteCount")
.HasColumnType("INTEGER");
b1.HasKey("Id");
b1.HasIndex("BookId");
b1.ToTable("BookRatings", (string)null);
b1.WithOwner()
.HasForeignKey("BookId");
});
b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 =>
{
b1.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b1.Property<Guid>("BookId")
.HasColumnType("TEXT");
b1.Property<string>("Format")
.IsRequired()
.HasMaxLength(6)
.HasColumnType("TEXT");
b1.Property<string>("Value")
.IsRequired()
.HasMaxLength(13)
.HasColumnType("TEXT")
.HasColumnName("ISBN");
b1.HasKey("Id");
b1.HasIndex("BookId");
b1.ToTable("BookISBNs", (string)null);
b1.WithOwner()
.HasForeignKey("BookId");
});
b.Navigation("ISBNs");
b.Navigation("Ratings");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
{
b.Navigation("RolePermissions");
b.Navigation("UserPermissions");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
{
b.Navigation("RolePermissions");
b.Navigation("UserRoles");
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
{
b.Navigation("Libraries");
b.Navigation("UserPermissions");
b.Navigation("UserRole");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,100 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations;
/// <inheritdoc />
public partial class ImplementsAuditColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Updated",
table: "Libraries",
newName: "UpdatedOnUtc");
migrationBuilder.RenameColumn(
name: "Created",
table: "Libraries",
newName: "CreatedOnUtc");
migrationBuilder.RenameColumn(
name: "Updated",
table: "Books",
newName: "UpdatedOnUtc");
migrationBuilder.RenameColumn(
name: "Created",
table: "Books",
newName: "CreatedOnUtc");
migrationBuilder.AddColumn<Guid>(
name: "CreatedBy",
table: "Libraries",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "UpdatedBy",
table: "Libraries",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "CreatedBy",
table: "Books",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "UpdatedBy",
table: "Books",
type: "TEXT",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "Libraries");
migrationBuilder.DropColumn(
name: "UpdatedBy",
table: "Libraries");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "Books");
migrationBuilder.DropColumn(
name: "UpdatedBy",
table: "Books");
migrationBuilder.RenameColumn(
name: "UpdatedOnUtc",
table: "Libraries",
newName: "Updated");
migrationBuilder.RenameColumn(
name: "CreatedOnUtc",
table: "Libraries",
newName: "Created");
migrationBuilder.RenameColumn(
name: "UpdatedOnUtc",
table: "Books",
newName: "Updated");
migrationBuilder.RenameColumn(
name: "CreatedOnUtc",
table: "Books",
newName: "Created");
}
}
@@ -245,7 +245,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<DateTime>("Created")
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT");
b.Property<string>("LibraryType")
@@ -259,7 +262,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<DateTime?>("Updated")
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT");
b.Property<Guid>("UserId")
@@ -292,7 +298,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(28);
b.Property<DateTime>("Created")
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(30);
@@ -405,7 +414,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<DateTime?>("Updated")
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(31);
@@ -686,8 +698,7 @@ namespace Lumina.DataAccess.Common.Migrations
b.Navigation("UserPermissions");
b.Navigation("UserRole")
.IsRequired();
b.Navigation("UserRole");
});
#pragma warning restore 612, 618
}
@@ -8,7 +8,6 @@ using Lumina.Domain.Common.Errors;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -131,7 +130,6 @@ internal sealed class UserRepository : IUserRepository
return Result.Updated;
}
/// <summary>
/// Gets a <see cref="UserEntity"/> identified by <paramref name="id"/> from the storage medium.
/// </summary>
@@ -64,4 +64,4 @@ public enum BookFormat
/// A book with three-dimensional paper engineering, creating pop-up or movable parts.
/// </summary>
PopupBook
}
}
@@ -24,4 +24,4 @@ public enum BookRatingSource
/// Ratings from Google Books, a service that searches the full text of books and magazines that Google has scanned and converted to text.
/// </summary>
GoogleBooks,
}
}
@@ -16,4 +16,4 @@ public enum IsbnFormat
/// Example: 978-0-306-40615-7
/// </summary>
Isbn13
}
}
@@ -18,12 +18,12 @@ public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
/// <summary>
/// Gets the date and time when the entity was created.
/// </summary>
public DateTime Created { get; set; }
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets the date and time when the entity was last updated.
/// </summary>
public DateTime? Updated { get; set; }
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
@@ -126,8 +126,8 @@ public sealed class Book : AggregateRoot<BookId>
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
/// <param name="created">The date and time when the entity was created.</param>
/// <param name="updated">The date and time when the entity was last updated.</param>
/// <param name="createdOnUtc">The date and time when the entity was created.</param>
/// <param name="updatedOnUtc">The date and time when the entity was last updated.</param>
/// <param name="isbns">The list of ISBNs of the book.</param>
/// <param name="contributors">The list of media contributors of the book.</param>
/// <param name="ratings">The list of ratings for the book.</param>
@@ -147,8 +147,8 @@ public sealed class Book : AggregateRoot<BookId>
Optional<string> googleBooksId,
Optional<string> barnesAndNobleId,
Optional<string> appleBooksId,
DateTime created,
Optional<DateTime> updated,
DateTime createdOnUtc,
Optional<DateTime> updatedOnUtc,
List<Isbn> isbns,
List<MediaContributorId> contributors,
List<BookRating> ratings) : base(id)
@@ -168,8 +168,8 @@ public sealed class Book : AggregateRoot<BookId>
GoogleBooksId = googleBooksId;
BarnesAndNobleId = barnesAndNobleId;
AppleBooksId = appleBooksId;
Created = created;
Updated = updated.HasValue ? updated.Value : null;
CreatedOnUtc = createdOnUtc;
UpdatedOnUtc = updatedOnUtc.HasValue ? updatedOnUtc.Value : null;
_isbns = isbns;
_contributors = contributors;
_ratings = ratings;
@@ -270,8 +270,8 @@ public sealed class Book : AggregateRoot<BookId>
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
/// <param name="created">The date and time when the entity was created.</param>
/// <param name="updated">The date and time when the entity was last updated.</param>
/// <param name="createdOnUtc">The date and time when the entity was created.</param>
/// <param name="updatedOnUtc">The date and time when the entity was last updated.</param>
/// <param name="isbns">The list of ISBNs of the book.</param>
/// <param name="contributors">The list of media contributors of the book.</param>
/// <param name="ratings">The list of ratings for the book.</param>
@@ -294,8 +294,8 @@ public sealed class Book : AggregateRoot<BookId>
Optional<string> googleBooksId,
Optional<string> barnesAndNobleId,
Optional<string> appleBooksId,
DateTime created,
Optional<DateTime> updated,
DateTime createdOnUtc,
Optional<DateTime> updatedOnUtc,
List<Isbn> isbns,
List<MediaContributorId> contributors,
List<BookRating> ratings)
@@ -317,8 +317,8 @@ public sealed class Book : AggregateRoot<BookId>
googleBooksId,
barnesAndNobleId,
appleBooksId,
created,
updated,
createdOnUtc,
updatedOnUtc,
isbns,
contributors,
ratings
@@ -41,7 +41,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/roles"
instance = "/api/v1/roles/{roleId}"
},
new
{
@@ -49,7 +49,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/roles"
instance = "/api/v1/roles/{roleId}"
},
new
{
@@ -57,7 +57,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/roles"
instance = "/api/v1/roles/{roleId}"
}
}
);
@@ -71,7 +71,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.Failure",
status = 403,
detail = "AdminRoleCannotBeDeleted",
instance = "/api/v1/roles",
instance = "/api/v1/roles/{roleId}",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
},
new
@@ -80,7 +80,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/roles",
instance = "/api/v1/roles/{roleId}",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
}
@@ -93,7 +93,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.NotFound",
status = 404,
detail = "RoleNotFound",
instance = "/api/v1/roles",
instance = "/api/v1/roles/{roleId}",
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
}
);
@@ -105,7 +105,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/roles",
instance = "/api/v1/roles/{roleId}",
errors = new Dictionary<string, string[]>
{
{
@@ -11,12 +11,12 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.GetRo
/// Class used for providing a textual description for the <see cref="GetRolesEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPermissionsEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
public class GetRolesEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetPermissionsEndpointSummary"/> class.
/// Initializes a new instance of the <see cref="GetRolesEndpointSummary"/> class.
/// </summary>
public GetPermissionsEndpointSummary()
public GetRolesEndpointSummary()
{
Summary = "Gets the collection of authorization roles.";
Description = "Gets the entire list of authorization roles.";
@@ -42,8 +42,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
ResponseParam<LibraryResponse>(r => r.Created, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.Updated, "The date and time when the entity was last updated.");
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
Response(201, "The media library was successfully created.", example:
@@ -53,8 +53,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
Title: "TV Shows",
LibraryType: LibraryType.TvShow,
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
Created: DateTime.UtcNow,
Updated: default
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
));
@@ -35,8 +35,8 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
ResponseParam<LibraryResponse>(r => r.Created, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.Updated, "The date and time when the entity was last updated.");
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
Response(200, "The media library is returned.", example: new LibraryResponse(
Id: Guid.NewGuid(),
@@ -44,8 +44,8 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
Title: "TV Shows",
LibraryType: LibraryType.TvShow,
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
Created: DateTime.UtcNow,
Updated: default
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
));
@@ -46,8 +46,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
ResponseParam<LibraryResponse>(r => r.Created, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.Updated, "The date and time when the entity was last updated.");
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
Response(200, "The media library was successfully updated.", example:
@@ -57,8 +57,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
Title: "TV Shows",
LibraryType: LibraryType.TvShow,
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
Created: DateTime.UtcNow,
Updated: default
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
));
@@ -169,8 +169,8 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
RequestParam(r => r.Ratings, "The list of ratings for this book. Required.");
ResponseParam<BookResponse>(r => r.Id, "The unique identifier of the entity.");
ResponseParam<BookResponse>(r => r.Created, "The date and time when the entity was created.");
ResponseParam<BookResponse>(r => r.Updated, "The date and time when the entity was last updated.");
ResponseParam<BookResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam<BookResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
ResponseParam<BookResponse>(r => r.Metadata, "The written content metadata of the book.");
ResponseParam<BookResponse>(r => r.Metadata.Title, "The title of the media item.");
ResponseParam<BookResponse>(r => r.Metadata.OriginalTitle, "The original title of the media item.");
@@ -276,8 +276,8 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
VoteCount: 87654
)
],
Created: DateTime.UtcNow,
Updated: default
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
)
);
@@ -128,8 +128,8 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
VoteCount: 87654
)
],
Created: DateTime.UtcNow,
Updated: default
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
),
new(
Id: Guid.NewGuid(),
@@ -229,8 +229,8 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
VoteCount: 90000
)
],
Created: DateTime.UtcNow,
Updated: default
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
)
}
);
@@ -42,7 +42,7 @@ public class GetUsersEndpoint : BaseEndpoint<EmptyRequest, IResult>
}
/// <summary>
/// Gets the list of authorization roles.
/// Gets the list of users.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
@@ -0,0 +1,71 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.UsersManagement.Users;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.GetUsers;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetUsersEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetUsersEndpointSummary : Summary<GetUsersEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetUsersEndpointSummary"/> class.
/// </summary>
public GetUsersEndpointSummary()
{
Summary = "Gets the collection of users.";
Description = "Gets the entire list of users.";
Response(200, "The list of users is returned.",
example: new[] {
new UserResponse(Id: Guid.NewGuid(), "TestUsername", DateTime.UtcNow, null)
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/auth/users"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/auth/users"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/auth/users"
}
}
);
Response(403, "The request failed because the current user is not an Admin.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/auth/users",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
}
}
@@ -31,6 +31,7 @@ public class StoreLastViewFilter : IActionFilter
if (context.Result is ViewResult)
{
HttpContext httpContext = context.HttpContext;
// ignore the login endpoint, because it is incorrect to be redirected to the login URL, with the login URL as the return URL
if (httpContext.Request.Path != "/en-us/auth/login")
httpContext.Session.SetString(HttpContextItemKeys.LAST_DISPLAYED_VIEW, $"{httpContext.Request.PathBase}{httpContext.Request.Path}{httpContext.Request.QueryString}");
}