public void OnAuthorization(AuthorizationContext filterContext) { if (!AuthorizationService.IsAllowed(UserSession.CurrentUser, op.ToOperation())) { var expl = AuthorizationService.GetAuthorizationInformation(UserSession.CurrentUser, op.ToOperation()).ToString(); filterContext.Result = new UnauthorizedViewResult(op, expl); } }
public void OnAuthorization(AuthorizationContext filterContext) { var rawValue = filterContext.Controller.ValueProvider.GetValue(param).AttemptedValue; var id = Convert.ToInt32(rawValue); var submission = Session.Get <Submission>(id); if (!AuthorizationService.IsAllowed(UserSession.CurrentUser, submission, op.ToOperation())) { var expl = AuthorizationService.GetAuthorizationInformation(UserSession.CurrentUser, submission , op.ToOperation()).ToString(); filterContext.Result = new UnauthorizedViewResult(op, expl); } }
public void OnAuthorization(AuthorizationContext filterContext) { if (lookFor == LookFor.SmartAss) { lookFor = LookFor.Contest; foreach (var kvp in smartAssLookUp) { if (filterContext.Controller.ValueProvider.GetValue(kvp.Key) != null) { lookFor = kvp.Value; param = kvp.Key; break; } } } var rawValue = filterContext.Controller.ValueProvider.GetValue(param).AttemptedValue; object id = lookFor == LookFor.TestInfo ? Guid.Parse(rawValue) : (object)Convert.ToInt32(rawValue); Contest contest; switch (lookFor) { case LookFor.TestInfo: contest = new TestInfoById { Id = (Guid)id }.Load(Session).Problem.Contest; break; case LookFor.Contest: contest = Session.Get <Contest>(id); break; case LookFor.Problem: contest = Session.Get <Problem>(id).Contest; break; case LookFor.Test: contest = Session.Get <Test>(id).Problem.Contest; break; default: throw new InvalidOperationException("Другие LookFor не подходят"); } if (!AuthorizationService.IsAllowed(UserSession.CurrentUser, contest, op.ToOperation())) { var expl = AuthorizationService.GetAuthorizationInformation(UserSession.CurrentUser, contest, op.ToOperation()).ToString(); filterContext.Result = new UnauthorizedViewResult(op, expl); } }