I have integrated MembershipReboot with a Breeze SPA application and the login and authorisztion work as expected. In the BreezeController.cs I have added the code below to capture an authorization failure.
[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class AuthorizeAttribute : System.Web.Http.Filters.AuthorizationFilterAttribute
{
public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
{
base.OnAuthorization(actionContext);
////check authentication and return if not authorized
if (actionContext != null)
{
if (!actionContext.RequestContext.Principal.Identity.IsAuthenticated)
{
actionContext.Response = actionContext.ControllerContext.Request.CreateResponse(System.Net.HttpStatusCode.Redirect);
System.Web.HttpContext.Current.Server.ClearError();
System.Web.HttpContext.Current.Response.Redirect("/UserAccount/Home",true);
//***********
//REDIRECT BEING CAUGHT BY ANGULAR ERROR HANDLER!!!
//**********
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
}
}
The lack of Authorization is caught when the code below is called:
[System.Web.Http.HttpGet]
[ValidateAntiForgeryToken]
[Authorize]
public string Metadata()
{
return _repository.Metadata;
}
However the redirect code is being loaded into the Toast error handler and displayed as an error and the redirect is not working.
Any ideas how I can get the code to run as opposed to being loaded into the error screen?