Add Tenant Id
This commit is contained in:
@@ -16,6 +16,7 @@ public sealed class RegisterUseCase : IRegisterUseCase
|
|||||||
private readonly ITenantResolver _tenantResolver;
|
private readonly ITenantResolver _tenantResolver;
|
||||||
private readonly IUnitOfWork _uow;
|
private readonly IUnitOfWork _uow;
|
||||||
private readonly IUserRepository _users;
|
private readonly IUserRepository _users;
|
||||||
|
private readonly ITenantRepository _tenants;
|
||||||
private readonly IPasswordHasher _hasher;
|
private readonly IPasswordHasher _hasher;
|
||||||
private readonly IHttpContextAccessor _http;
|
private readonly IHttpContextAccessor _http;
|
||||||
|
|
||||||
@@ -23,10 +24,16 @@ public sealed class RegisterUseCase : IRegisterUseCase
|
|||||||
ITenantResolver resolver,
|
ITenantResolver resolver,
|
||||||
IUnitOfWork uow,
|
IUnitOfWork uow,
|
||||||
IUserRepository users,
|
IUserRepository users,
|
||||||
|
ITenantRepository tenants,
|
||||||
IPasswordHasher hasher,
|
IPasswordHasher hasher,
|
||||||
IHttpContextAccessor http)
|
IHttpContextAccessor http)
|
||||||
{
|
{
|
||||||
_tenantResolver = resolver; _uow = uow; _users = users; _hasher = hasher; _http = http;
|
_tenantResolver = resolver;
|
||||||
|
_uow = uow;
|
||||||
|
_users = users;
|
||||||
|
_tenants = tenants;
|
||||||
|
_hasher = hasher;
|
||||||
|
_http = http;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RegisterResponse?> ExecuteAsync(RegisterRequest request, CancellationToken ct = default)
|
public async Task<RegisterResponse?> ExecuteAsync(RegisterRequest request, CancellationToken ct = default)
|
||||||
@@ -48,8 +55,11 @@ public sealed class RegisterUseCase : IRegisterUseCase
|
|||||||
|
|
||||||
var hash = _hasher.Hash(request.Password);
|
var hash = _hasher.Hash(request.Password);
|
||||||
|
|
||||||
|
var tn = await _tenants.GetAsync(request.Tenant);
|
||||||
|
|
||||||
var user = new User
|
var user = new User
|
||||||
{
|
{
|
||||||
|
TenantId = tn.TenantId,
|
||||||
PasswordHash = hash,
|
PasswordHash = hash,
|
||||||
IsActive = true,
|
IsActive = true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace AMREZ.EOP.Domain.Entities.Tenancy;
|
|||||||
|
|
||||||
public sealed class TenantConfig
|
public sealed class TenantConfig
|
||||||
{
|
{
|
||||||
|
public Guid TenantId { get; set; } = Guid.NewGuid();
|
||||||
public string TenantKey { get; set; } = default!;
|
public string TenantKey { get; set; } = default!;
|
||||||
public string? Schema { get; set; }
|
public string? Schema { get; set; }
|
||||||
public string? ConnectionString { get; set; }
|
public string? ConnectionString { get; set; }
|
||||||
|
|||||||
1539
AMREZ.EOP.Infrastructures/Migrations/20250930101327_Add_Tenant_Guid.Designer.cs
generated
Normal file
1539
AMREZ.EOP.Infrastructures/Migrations/20250930101327_Add_Tenant_Guid.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AMREZ.EOP.Infrastructures.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Add_Tenant_Guid : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "TenantId",
|
||||||
|
schema: "meta",
|
||||||
|
table: "tenants",
|
||||||
|
type: "uuid",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TenantId",
|
||||||
|
schema: "meta",
|
||||||
|
table: "tenants");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1240,6 +1240,9 @@ namespace AMREZ.EOP.Infrastructures.Migrations
|
|||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("character varying(128)");
|
||||||
|
|
||||||
|
b.Property<Guid>("TenantId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("UpdatedAtUtc")
|
b.Property<DateTimeOffset>("UpdatedAtUtc")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
|||||||
Reference in New Issue
Block a user