Remove LightContext #205
Description
As attested during the discussion on #198, the class LightContext
has little semantic value for Liquid. It's a holder for a ClaimsPrincipal
, just that.
Now that #204 removed the authorization code from LightWorker
, LightContext
is just used by LightController
, and in the most weird manner:
You can see all sorts of strange things in this code:
-
LightController
defines both thisGetContext
method (which is private) and a protected field_context
, so there are two ways of accessing aLightContext
from the controller. However, upon further inspection, one can see that the field isn't ever written to. -
The method passes a
IHttpContextAccessor
to theLightContext
constructor. This is stored in a public field of theLightContext
. Also, the User property is manually assigned to by the method with the User obtained from theHttpContext
. The same user that is available through _httpContextAccessor, so we are effectively transmitting the same data twice. -
The domain shouldn't access HTTP context data. This is a violation of the responsibility of the domain.
For all those reasons, I suggest we obsolete and remove LightContext
, replacing it with more semantic types when necessary.