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

@@ -45,7 +45,7 @@ public class UserService : IUserService
: authorizedAddressesString.Split(';', StringSplitOptions.RemoveEmptyEntries);
}
public async Task<User> Authenticate(string name, string address, string message, string signature)
public async Task<User> Authenticate(string name, string address, string message, string signature, string? ownerWalletAddress = null)
{
var recoveredAddress = _evmManager.VerifySignature(signature, message);
@@ -106,6 +106,13 @@ public class UserService : IUserService
throw new Exception("Account not found for address " + recoveredAddress);
}
// Update owner wallet address if provided and user doesn't have one set yet
if (!string.IsNullOrEmpty(ownerWalletAddress) && string.IsNullOrEmpty(user.OwnerWalletAddress))
{
user.OwnerWalletAddress = ownerWalletAddress;
await _userRepository.SaveOrUpdateUserAsync(user);
}
return user;
}
else
@@ -113,7 +120,8 @@ public class UserService : IUserService
// First login - create user first
user = new User
{
Name = name
Name = name,
OwnerWalletAddress = ownerWalletAddress ?? string.Empty
};
// Save the user first