Building an MVC5 application and I am using my custom authorization with windows authentication. The live project is authenticating from an active directory. During development I want the anonymous user to access the app as administrator as that would help me during the development process.
My custom class:
public class MyAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
#if DEBUG
//TODO: set anonymous user as administrator during developement
return true;
#else
return base.AuthorizeCore(httpContext);
#endif
}
}
This article helped me a lot but I just need to add the admin role if possible.
Is there a way to add a role to the anonymous user during the development process? For me to use the attribute as such in debug mode
User.IsInRole("Admin") == true