Just for anybody with my my doubt, add claims to the ClaimPrincipal doesn't require to add a new ClaimType using await _identityClaimTypeManager.CreateAsync(claimType).
I can directly add claims to the ClaimPrincipal as maliming mention.
Appreciated your answer, nice and easy.
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
Hi support team, I'm stuck trying to add a claim to the ICurrentUser & ICurrentPrincipalAccessor each time the user login. The idea is get the value from a custom attribute using AppUser entity approach and set a claim ready to use with my claim principal. As I have read several articles around the topic, here and here. However, they seem to be obsoletes please, correct me if I'm wrong, and I not sure how to implement in the current version of ** abp framework community (4.2.1)**:
Trying to visualize the approach, I was thinking on this steps:
await _identityClaimTypeManager.CreateAsync(claimType)
to create a new claimtype.
As I understand, this action should be executed only one time to add the type to the database AbpClaimType table.Correct?, is sedding the database at migration time an option?
and then, I can see two options:
2.1 Get the value from the custom attribute and set the claim each time the user login.
2.2 Create a custom claim using the claimtype created previously and set the value from the attribute (AppUser) and save them in AbpUserClaim table.
does it makes sense for you?, any other options?
At the end, the goal is get the claim from the iCurrentUser like others claims.
Let me know if you need more clarification on what I want to achieve and thanks so much for pointing me out the solution, Jose Manuel Gonzalez
So much clear now, I appreciated so much your support.
Thanks liangshiwei, My name is Jose, Ok, the link that you send makes sense for me, I had read before but it's not always easy to get the right direction.
As a summary, the call from the Front End to the application service is intercepted by the HttpClient and redirected to HttpAPI.Host endpoint. Correct?
Therefore, could we say that the call to the method CreateAsync from the Post request of the client razor page it's not executed?
And, please, could you point me to the code where this magic is done?, is it a middleware injected into the request pipeline?
~~At last, but not least is it the code behind PostAsync Method of my razor page (or in this case the Tenant Management module) executed?~~
Thanks so much, Jose
Dear support team,
I have a question about communication between FrontEnd (Razor page) & Web API. The example use: abp new Sample.Tiered --tiered
to create a sample application with 3 executables (Web, HttpAPI.Host and IdentityServer).
I that situation, my expectations are comsume the HttpAPI.Host from Web in every request. To test it, I followed this tutorial, to up & running the application.
The test is to create a Create Tenant request and confirm the behavior of the application. After executed the request, the log shows me this output in the Front End (Web)
Inside the red frame, the log entry says:
[06:26:28 INF] Executing handler method Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants.CreateModalModel.OnPostAsync - ModelState is Valid
. If you follow OnPostAsync of the TenantManagement Module. The method CreateAsync
in the ApplicationService TenantAppService
will be execute with the corresponding logic call to repositories, unit of work and save to persistence. Probably, this call is redirected to API, blocked or something but I cannot see.
And, the next entry in the log is:
[06:26:28 INF] Start processing HTTP request POST https://localhost:44372/api/multi-tenancy/tenants?api-version=1.0
As I expected, a request to the web API for processing the CreateAsync
Where is this request iniciated against the HttpAPI?
From the HttpAPI point of view, you can see the piece of log in the next image, the API is processing the request using a controller calling the method CreateAsync
in the ApplicationService TenantAppService
and so on.
Is the application behavior trying to execute CreateAsync method in the TenantAppService of the TenantManagement Module twice?, one in the Front End and the other in the HttpAPI request.
Obiously, If you inspect the database, only one tenant is created, then I need to understand how this request is working and how the first call to CreateAsync method is redirected to the web API.
Hopefully, I explanied well, if not, please let me know. Thanks, Jose