I will send you jwt by e-mail
Thank you for your answer, but we have existing saas, identity, administration services. APIs in our other projects can send requests here and perform tenant and auth authentications in these services. We want to make this screen design service work the same way. What settings do we need to make?
In the example you sent, it changes the existing tenant system, this is not suitable for us.
This image is a screenshot of our saas project, currently working:
This class is a consumer class, not a domain service or application. I get Currenttenant or CurrentUser with dependency injection. I can't use it with the CurrentTenant global variable.
In the scenario of the code below, although two IDs are filled, it only writes the creatorId to the database.
If you want to check the project, I'm adding the link. https://we.tl/t-RkLhH4N3mA
public class CreateScreenDesignConsumer : IConsumer<IScreenDesignCreateCommand>, ITransientDependency
{
private readonly IScreenRootManager _screenRootManager;
private readonly ILogger<CreateScreenDesignConsumer> _logger;
private readonly ICurrentPrincipalAccessor _currentPrincipalAccessor;
private readonly ICurrentTenant _currentTenant;
private readonly ICurrentUser _currentUser;
public CreateScreenDesignConsumer(IScreenRootManager screenRootManager, ILogger<CreateScreenDesignConsumer> logger, ICurrentPrincipalAccessor currentPrincipalAccessor, ICurrentTenant currentTenant, ICurrentUser currentUser)
{
_screenRootManager = screenRootManager;
_logger = logger;
_currentPrincipalAccessor = currentPrincipalAccessor;
_currentTenant = currentTenant;
_currentUser = currentUser;
}
public virtual async Task Consume(ConsumeContext<IScreenDesignCreateCommand> context)
{
var jwtHeader = context.Headers.Get<string>("jwt");
var handler = new JwtSecurityTokenHandler();
var jsonToken = handler.ReadToken(jwtHeader) as JwtSecurityToken;
var userId = jsonToken.Payload.Sub;
var tenantId = jsonToken.Payload["tenantid"].ToString();
var newPrincipal = new ClaimsPrincipal(
new ClaimsIdentity(
new Claim[]
{
new Claim(AbpClaimTypes.UserId, userId),
// new Claim(AbpClaimTypes.TenantId, tenantId)
}
)
);
using (_currentTenant.Change(Guid.Parse(tenantId)));
using (_currentPrincipalAccessor.Change(newPrincipal))
{
//tmptenantid value is null
var tmptenantid = _currentTenant.Id;
var tmpuserid = _currentUser.Id;
try
{
var result = await _screenRootManager.CreateAsync(context.Message);
await context.RespondAsync(new Result<ScreenDesignCreateResult>(data: result));
}
catch (Exception ex)
{
await context.RespondAsync<Fault<Result>>
(new { Message = "ScreenDeisgn:CreateFail", FaultMessage = ex.Message, FaultStackTrace = ex.StackTrace });
}
}
}
}
Hi, Can you schedule a meeting today at 10:00 GMT+3 or according to your availability? I saw it late in your yesterday's email.
It works for us too, I can show it with zoom if you want. my mail : ali.ozen@teknosol.com.tr