You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
675 B
22 lines
675 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace webApiTokenAuthentication
|
|
{
|
|
public class AuthorizeAttribute : System.Web.Http.AuthorizeAttribute
|
|
{
|
|
protected override void HandleUnauthorizedRequest(System.Web.Http.Controllers.HttpActionContext actionContext)
|
|
{
|
|
if (!HttpContext.Current.User.Identity.IsAuthenticated)
|
|
{
|
|
base.HandleUnauthorizedRequest(actionContext);
|
|
}
|
|
else
|
|
{
|
|
actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Forbidden);
|
|
}
|
|
}
|
|
}
|
|
} |