أنشطة "pablo@ccalp.net"

إجابة

How can I use my own guard in the "route.provider.ts" I need to hide/show menu items based on my own logic, not the "requiredPolicy" property.

سؤال
  • ABP Framework version: v7.2.x
  • UI type: Angular
  • DB provider: EF Core

I need guidance to accomplish the following:

We need to implement a custom permissions system based on levels and not individual rights, so for example, a user or role will have one of the following levels on a feature or module:

Users => [ X ] Deny | [ ] Read | [ ] Write | [ ] Delete Roles => [ ] Deny | [ X ] Read | [ ] Write | [ ] Delete Feature A => [ ] Deny | [ ] Read | [ X ] Write | [ ] Delete Feature B => [ ] Deny | [ ] Read | [ ] Write | [ X ] Delete

What would be the best approach to extend, replace, or override the current behavior of the [Authorize] attribute, or would it be better to implement our own?

On the Angular side, I suppose we need to create our own guards and check the configuration to evaluate the permissions, or something along those lines.

Thanks.

One more questions: What do I have to do to merge the host and the tenant DbContext, so basically not to separate the host from the tenant databases.

Ok, so if I wanted to add a foreign key in the AbpUsers to another table, that table must exist in the Host and the Tenant databases, right? BTW, I have the host and tenant DbContexts separated.

I cannot share my project and will take too long to create a sample with the right conditions. My use case is very simple: Is it possible to tell the ObjectExtensionManager that the mappings are just for the Tenant and not for the host? Just like when creating the model builder.SetMultiTenancySide(MultiTenancySides.Tenant);

Or is there any other way to add the additional columns to the AbpUsers table?

  • ABP Framework version: v7.2
  • UI type: Angular
  • DB provider: EF Core

Hello, I need to extend the IdentityUser just for the tenants, I'm using the EfCoreEntityExtensionMappings class but when I run the migration I get an error because I assume that one of the foreign keys to a table that only exists in the tenant databases is not present in the host. How can I just extend the IdentityUser just for the tenants?

Extension mapping code here:

using CompuCare.Entities;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
namespace CompuCare.EntityFrameworkCore;
public static class CompuCareEfCoreEntityExtensionMappings
{
    private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
    public static void Configure()
    {
        CompuCareGlobalFeatureConfigurator.Configure();
        CompuCareModuleExtensionConfigurator.Configure();

        OneTimeRunner.Run(() =>
        {
            ObjectExtensionManager.Instance
                .MapEfCoreProperty<IdentityUser, string>(
                    "SSN",
                    (entityBuilder, propertyBuilder) =>
                    {
                        propertyBuilder.HasMaxLength(9);
                    }
                )
                .MapEfCoreProperty<IdentityUser, int?>(
                    "DoctorId",
                    (entityBuilder, propertyBuilder) =>
                    {
                        propertyBuilder.IsRequired(false);
                        entityBuilder.HasOne(typeof(Entities.Doctor))
                            .WithMany()
                            .IsRequired(false);
                    }
                )
                .MapEfCoreProperty<IdentityUser, int?>(
                    "TypeId",
                    (entityBuilder, propertyBuilder) =>
                    {
                        propertyBuilder.IsRequired(false);
                        entityBuilder.HasOne(typeof(Entities.Type))
                            .WithMany()
                            .IsRequired(false);
                    }
                );
        });
    }
}

Migration that was created:

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompuCare.TenantMigrations
{
    /// <inheritdoc />
    public partial class IdentityUserExtraProperties : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "DoctorId",
                table: "AbpUsers",
                type: "int",
                nullable: true);
            migrationBuilder.AddColumn<string>(
                name: "SSN",
                table: "AbpUsers",
                type: "nvarchar(9)",
                maxLength: 9,
                nullable: true);
            migrationBuilder.AddColumn<int>(
                name: "TypeId",
                table: "AbpUsers",
                type: "int",
                nullable: true);
            migrationBuilder.CreateIndex(
                name: "IX_AbpUsers_DoctorId",
                table: "AbpUsers",
                column: "DoctorId");
            migrationBuilder.CreateIndex(
                name: "IX_AbpUsers_TypeId",
                table: "AbpUsers",
                column: "TypeId");
            migrationBuilder.AddForeignKey(
                name: "FK_AbpUsers_Doctors_DoctorId",
                table: "AbpUsers",
                column: "DoctorId",
                principalTable: "Doctors",
                principalColumn: "Id");
            migrationBuilder.AddForeignKey(
                name: "FK_AbpUsers_Types_TypeId",
                table: "AbpUsers",
                column: "TypeId",
                principalTable: "Types",
                principalColumn: "Id");
        }
        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AbpUsers_Doctors_DoctorId",
                table: "AbpUsers");
            migrationBuilder.DropForeignKey(
                name: "FK_AbpUsers_Types_TypeId",
                table: "AbpUsers");
            migrationBuilder.DropIndex(
                name: "IX_AbpUsers_DoctorId",
                table: "AbpUsers");
            migrationBuilder.DropIndex(
                name: "IX_AbpUsers_TypeId",
                table: "AbpUsers");
            migrationBuilder.DropColumn(
                name: "DoctorId",
                table: "AbpUsers");
            migrationBuilder.DropColumn(
                name: "SSN",
                table: "AbpUsers");
            migrationBuilder.DropColumn(
                name: "TypeId",
                table: "AbpUsers");
        }
    }
}
سؤال
  • ABP Framework version: v7.2
  • UI type: Angular
  • DB provider: EF Core

I'm trying to create an entity with a DateOnly field type, but when creating a migration I'm getting the following message:

The 'DateOnly?' property 'AccountingDeposit.BankPostingDate' could not be mapped to the database type 'date' because the database provider does not support mapping 'DateOnly?' properties to 'date' columns. Consider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

I'm using a value converter as suggested.

protected override void ConfigureConventions(ModelConfigurationBuilder builder)
{
    builder.Properties&lt;DateOnly&gt;()
        .HaveConversion&lt;DateOnlyConverter&gt;()
        .HaveColumnType("date");

    base.ConfigureConventions(builder);
}

Please advice on how to proceed.

I think I figured it out, thank you. Would I take the same approach to host a Hangfire server independently from the main API?

Trying to create the service as suggested but getting an error that says: Could not find a part of the path 'C:\Repos\CompuCare\aspnet-core\apps\auth-server'.

Will this work if I'm not using a microservice architecture?

عرض 31 الي 40 من 57 إدخالات
Made with ❤️ on ABP v8.2.0-preview Updated on مارس 25, 2024, 15:11