Enhance user authentication by adding optional OwnerWalletAddress parameter in LoginRequest and UserService. Update UserController and related components to support the new wallet address functionality, ensuring better user profile management and validation in trading operations.

This commit is contained in:
2025-11-17 13:48:05 +07:00
parent 8697f1598d
commit 06ef33b7ab
15 changed files with 1802 additions and 28 deletions

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UpdateKudaiStakingValidation : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "OwnerWalletAddress",
table: "Users",
type: "text",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OwnerWalletAddress",
table: "Users");
}
}
}

View File

@@ -1418,6 +1418,9 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<string>("OwnerWalletAddress")
.HasColumnType("text");
b.Property<string>("TelegramChannel")
.HasMaxLength(255)
.HasColumnType("character varying(255)");

View File

@@ -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 string? OwnerWalletAddress { get; set; }
public bool IsAdmin { get; set; }
// Navigation properties

View File

@@ -130,6 +130,7 @@ public static class PostgreSqlMappers
AgentName = entity.AgentName,
AvatarUrl = entity.AvatarUrl,
TelegramChannel = entity.TelegramChannel,
OwnerWalletAddress = entity.OwnerWalletAddress,
Id = entity.Id, // Assuming Id is the primary key for UserEntity
IsAdmin = entity.IsAdmin,
Accounts = entity.Accounts?.Select(MapAccountWithoutUser).ToList() ?? new List<Account>()
@@ -165,6 +166,7 @@ public static class PostgreSqlMappers
AgentName = user.AgentName,
AvatarUrl = user.AvatarUrl,
TelegramChannel = user.TelegramChannel,
OwnerWalletAddress = user.OwnerWalletAddress,
IsAdmin = user.IsAdmin
};
}

View File

@@ -45,7 +45,8 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
Name = u.Name,
AgentName = u.AgentName,
AvatarUrl = u.AvatarUrl,
TelegramChannel = u.TelegramChannel
TelegramChannel = u.TelegramChannel,
OwnerWalletAddress = u.OwnerWalletAddress
})
.FirstOrDefaultAsync()
.ConfigureAwait(false);
@@ -93,7 +94,8 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
Name = u.Name,
AgentName = u.AgentName,
AvatarUrl = u.AvatarUrl,
TelegramChannel = u.TelegramChannel
TelegramChannel = u.TelegramChannel,
OwnerWalletAddress = u.OwnerWalletAddress
})
.FirstOrDefaultAsync()
.ConfigureAwait(false);
@@ -208,7 +210,8 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
Name = u.Name,
AgentName = u.AgentName,
AvatarUrl = u.AvatarUrl,
TelegramChannel = u.TelegramChannel
TelegramChannel = u.TelegramChannel,
OwnerWalletAddress = u.OwnerWalletAddress
})
.ToListAsync()
.ConfigureAwait(false);
@@ -249,6 +252,7 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
existingUser.AgentName = user.AgentName;
existingUser.AvatarUrl = user.AvatarUrl;
existingUser.TelegramChannel = user.TelegramChannel;
existingUser.OwnerWalletAddress = user.OwnerWalletAddress;
existingUser.IsAdmin = user.IsAdmin;
_context.Users.Update(existingUser);