Update API-Token
This commit is contained in:
22
API_NetFramework - Kopie/AuthorizeAttribute.cs
Normal file
22
API_NetFramework - Kopie/AuthorizeAttribute.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user