public override void OnActionExecuting(HttpActionContext actionContext, UnityActionFilterAttribute attribute) { if (_identity.GetUserInfo() == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } _auditContext.Operation = ((AuditOperationAttribute)attribute).Operation; }
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext, UnityActionFilterAttribute attribute) { if (!_executed && IsSuccess(actionExecutedContext.Response.StatusCode)) { throw new Exception("Action should call EditathonCode.Get()"); } }
public override void OnActionExecuting(HttpActionContext actionContext, UnityActionFilterAttribute attribute) { var code = actionContext.ActionArguments.Values.OfType <EditathonCode>().SingleOrDefault(); if (code == null) { throw new Exception("Action should have EditathonCode in its arguments."); } var user = _identity.GetUserInfo(); if (user == null) { throw Unauthorized(); } code.QueryModifiers.Add(q => q.Fetch(_ => _.Jury)); code.Validators.Add(e => { _executed = true; if (!e.Jury.Contains(user.Username)) { throw Forbidden(); } }); }