Blazor server: cunstruct scoped service but after retrieving addidtional data

31 Views Asked by At

I'm new to Blazor, I'm wondering how to solve a problem that my scoped service should be constructed after user log in and retrieve it's login/pass to instantiate that service.

Case is to establish connection with ERP (which can even take up to 10sec), with user's specific login/pass after user log in to the webapp.

It's tempting for me to just create custom MyClaimsPrincipal class, then put ERP class as a property of MyClaimsPrincipal class, so I could access the ERP instance through MyAuthenticationStateProvider service instance's User.

Is it anything wrong with this kind of solution?

Or maybe I should create MyERP "wrapper" class which could be constructed without any params, put it as a scoped service, then as user loggs in, on GetAuthenticationStateAsync construct the ERP object?

0

There are 0 best solutions below