views:

142

answers:

1

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
    {
        return (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...

A: 

I have found this answer, which looks like it may help:

http://stackoverflow.com/questions/1699913/setup-a-route-tenant-controller-action-id-with-asp-net-mvc

will work through that and see if it answers my own question...

Mark Redman
not sure that is the way to go as the check needs to be done regardless of any additional data attached to the authentication cookie...
Mark Redman