public static string SecuredAction<T>(Person person, Expression<Action<T>> routeExpression, string grantedFormat, string deniedFormat) where T : Controller
 {
     var body = SitkaRoute<T>.GetRouteExpressionBody(routeExpression);
     var neptuneFeatureLookupAttribute = body.Method.GetCustomAttributes(typeof(NeptuneBaseFeature), true).Cast<NeptuneBaseFeature>().SingleOrDefault();
     Check.RequireNotNull(neptuneFeatureLookupAttribute, string.Format("Could not find feature for {0}", SitkaRoute<T>.BuildUrlFromExpression(routeExpression)));
     return neptuneFeatureLookupAttribute.HasPermissionByPerson(person) ? String.Format("<a href=\"{0}\">{1}</a>", SitkaRoute<T>.BuildUrlFromExpression(routeExpression), grantedFormat) : deniedFormat;
 }
示例#2
0
        public static string GenerateLogInUrlWithReturnUrl(string returnUrl)
        {
            var logInUrl = SitkaRoute <AccountController> .BuildUrlFromExpression(c => c.LogOn());

            return(OnErrorOrNotFoundPage(returnUrl) ? logInUrl : $"{logInUrl}?returnUrl={HttpUtility.UrlEncode(returnUrl)}");
        }