Open hishamco opened 1 week ago
I didn't realize there were many places :) I just notice it in that place. I will fix it in all the places
I don't think you should remove the null check. If the request come from a non HTTP request like background task, there won't be user.
If the request come from a non HTTP request like background task, there won't be user.
We might need a unit test for that
We might need a unit test for that
I would not make such a global change blindly. I would address them case by case if needed. It's probably safer to leave everything as is and close the PR :)
If that's the case I presume to see all .NET Core libraries using nullable users. I will make a unit or integration test to make sure that the user could not be null
If I'm not wrong one of the use cases that we have is HTTP Workflow
@hishamco if you like me think this PR is not useful, please close it.
The question why did you add the nullable operator :)
as previously explained, HttpContext could be null if the request is not HTTP like from a background task.
If you are right the User
will be null all the time, let me create a unit or functional test for that instead of a long discussion :)
As per the nullable annotations, IHttpContextAccess.HttpContext?
can be null, but HttpContext.User
is never null.
https://github.com/search?q=repo%3AOrchardCMS%2FOrchardCore%20.HttpContext%3F.User&type=code