Add whitelisting and admin
This commit is contained in:
1605
src/Managing.Infrastructure.Database/Migrations/20251107163433_AddIsAdminToUsers.Designer.cs
generated
Normal file
1605
src/Managing.Infrastructure.Database/Migrations/20251107163433_AddIsAdminToUsers.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Managing.Infrastructure.Databases.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddIsAdminToUsers : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAdmin",
|
||||
table: "Users",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAdmin",
|
||||
table: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1306,6 +1306,9 @@ namespace Managing.Infrastructure.Databases.Migrations
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("character varying(500)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
|
||||
@@ -13,6 +13,7 @@ public class UserEntity
|
||||
[MaxLength(255)] public string? AgentName { get; set; }
|
||||
public string? AvatarUrl { get; set; }
|
||||
public string? TelegramChannel { get; set; }
|
||||
public bool IsAdmin { get; set; } = false;
|
||||
|
||||
// Navigation properties
|
||||
public virtual ICollection<AccountEntity> Accounts { get; set; } = new List<AccountEntity>();
|
||||
|
||||
@@ -131,6 +131,7 @@ public static class PostgreSqlMappers
|
||||
AvatarUrl = entity.AvatarUrl,
|
||||
TelegramChannel = entity.TelegramChannel,
|
||||
Id = entity.Id, // Assuming Id is the primary key for UserEntity
|
||||
IsAdmin = entity.IsAdmin,
|
||||
Accounts = entity.Accounts?.Select(MapAccountWithoutUser).ToList() ?? new List<Account>()
|
||||
};
|
||||
}
|
||||
@@ -163,7 +164,8 @@ public static class PostgreSqlMappers
|
||||
Name = user.Name,
|
||||
AgentName = user.AgentName,
|
||||
AvatarUrl = user.AvatarUrl,
|
||||
TelegramChannel = user.TelegramChannel
|
||||
TelegramChannel = user.TelegramChannel,
|
||||
IsAdmin = user.IsAdmin
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
|
||||
existingUser.AgentName = user.AgentName;
|
||||
existingUser.AvatarUrl = user.AvatarUrl;
|
||||
existingUser.TelegramChannel = user.TelegramChannel;
|
||||
existingUser.IsAdmin = user.IsAdmin;
|
||||
|
||||
_context.Users.Update(existingUser);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user