Exemple #1
0
        public static Uri PostLogonDestinationImpl(Uri requestUrl, Uri requestReferrer)
        {
            Uri postLogonDestination;

            var logonAbsolutePath = new Uri(SitkaRoute <AccountController> .BuildUrlFromExpression(c => c.LogOn())).AbsolutePath;

            if (logonAbsolutePath != requestUrl?.AbsolutePath)
            {
                postLogonDestination = requestUrl;
            }
            else
            {
                postLogonDestination = requestReferrer;
                if (postLogonDestination == null)
                {
                    postLogonDestination = logonAbsolutePath != requestUrl.AbsolutePath
                        ? requestUrl
                                           // default to prevent landing on the clean-up page
                        : new Uri(SitkaRoute <HomeController> .BuildUrlFromExpression(x => x.Index()));
                }
            }

            return(postLogonDestination);
        }
Exemple #2
0
 public static RedirectResult RedirectToActionStatic <T>(SitkaRoute <T> route) where T : Controller
 {
     return(new RedirectResult(route.BuildUrlFromExpression()));
 }
Exemple #3
0
 protected ActionResult RedirectToActionWithError <T>(SitkaRoute <T> route, string error) where T : Controller
 {
     SetErrorForDisplay(error);
     return(RedirectToActionStatic(route));
 }
Exemple #4
0
 protected RedirectResult RedirectToAction <T>(SitkaRoute <T> route) where T : Controller
 {
     return(RedirectToActionStatic(route));
 }
 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;
 }
Exemple #6
0
        public static string GenerateLogInUrlWithReturnUrl(string returnUrl)
        {
            var logInUrl = SitkaRoute <AccountController> .BuildUrlFromExpression(c => c.LogOn());

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