Add cursor and privy provider
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Users;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Managing.Application.Users;
|
||||
|
||||
@@ -10,24 +11,28 @@ public class UserService : IUserService
|
||||
private readonly IEvmManager _evmManager;
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly IAccountService _accountService;
|
||||
private readonly ILogger<UserService> _logger;
|
||||
|
||||
private string[] authorizedAddresses = [
|
||||
private string[] authorizedAddresses =
|
||||
[
|
||||
"0x6781920674dA695aa5120d95D80c4B1788046806", // Macbook
|
||||
"0xA2B43AFF0992a47838DF2e6099A8439981f0B717", // Phone
|
||||
"0xAD4bcf258852e9d47E580798d312E1a52D59E721", // Razil
|
||||
"0xAd6D6c80910096b40e45690506a9f1052e072dCB", // Teru
|
||||
"0x309b9235edbe1C6f840816771c6C21aDa6c275EE", // Cowchain
|
||||
"0x23AA99254cfaA2c374bE2bA5B55C68018cCdFCb3" // Local optiflex
|
||||
"0x23AA99254cfaA2c374bE2bA5B55C68018cCdFCb3", // Local optiflex
|
||||
"0x932167388dD9aad41149b3cA23eBD489E2E2DD78" // Embedded wallet
|
||||
];
|
||||
|
||||
public UserService(
|
||||
IEvmManager evmManager,
|
||||
IUserRepository userRepository,
|
||||
IAccountService accountService)
|
||||
IAccountService accountService, ILogger<UserService> logger)
|
||||
{
|
||||
_evmManager = evmManager;
|
||||
_userRepository = userRepository;
|
||||
_accountService = accountService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<User> Authenticate(string name, string address, string message, string signature)
|
||||
@@ -35,10 +40,16 @@ public class UserService : IUserService
|
||||
var recoveredAddress = _evmManager.VerifySignature(signature, message);
|
||||
|
||||
if (!authorizedAddresses.Contains(recoveredAddress))
|
||||
{
|
||||
_logger.LogWarning($"Address {recoveredAddress} not authorized");
|
||||
throw new Exception("Address not authorized");
|
||||
}
|
||||
|
||||
if (recoveredAddress == null || !recoveredAddress.Equals(address))
|
||||
{
|
||||
_logger.LogWarning($"Address {recoveredAddress} not corresponding");
|
||||
throw new Exception("Address not corresponding");
|
||||
}
|
||||
|
||||
// Check if account exist
|
||||
var account = await _accountService.GetAccountByKey(recoveredAddress, true, false);
|
||||
@@ -97,4 +108,4 @@ public class UserService : IUserService
|
||||
user.Accounts = _accountService.GetAccountsByUser(user).ToList();
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user