asp.net MVC Multi-tenancy: Is there a way to override/influence User.Identity.IsAuthenticated?
I have a custom memebership provider that has served us well for asp.net web forms applications and am now using it in a new asp.net MVC multi-tenancy application.
The membership provider works well in MVC, just as within webforms, but now want to add an additional constraint where we can check if a User is both authenticated and authenticated for a specific "Tenant". We are currently tracking the current "TenantID" based on URLs and detect any changes to URLs and instead of just checking User.Identity.IsAuthenticated, we have something like this in our Controller and View base classes.
public bool UserIsAuthenticated
{
get
{
retu开发者_如何转开发rn (User.Identity.IsAuthenticated && LoggedInUserTenantID == CurrentTenantID);
}
}
How can we override/replace User.Identity.IsAuthenticated so we can use that directly?
Any suggestions or comments on the above welcome...
I have found this answer, which looks like it may help:
Setup a route {tenant}/{controller}/{action}/{id} with ASP.NET MVC?
will work through that and see if it answers my own question...
EDIT/UPDATE:
I eventually came to this solution:
The User.Identity.IsAuthenticated is not influenced at all, all Forms Authentication is used as-is and other checks are done via the Tenant/Subdmain detection.
精彩评论