/// <summary> /// Provides a link to the login page, or if the user is logged in, the logout page. /// Optional prefix and suffix tags or seperators and also included. /// </summary> /// <returns>If windows authentication is being used, an empty string is returned.</returns> public static MvcHtmlString LoginLink(this HtmlHelper helper, string prefix, string suffix) { ControllerBase controller = helper.ViewContext.Controller as ControllerBase; if (controller == null || controller.ApplicationSettings.UseWindowsAuthentication) { return(MvcHtmlString.Empty); } string link = ""; if (controller.Context.IsLoggedIn) { link = helper.ActionLink(SiteStrings.Navigation_Logout, "Logout", "User").ToString(); } else { string redirectPath = helper.ViewContext.HttpContext.Request.Path; link = helper.ActionLink(SiteStrings.Navigation_Login, "Login", "User", new { ReturnUrl = redirectPath }, null).ToString(); if (controller.SettingsService.GetSiteSettings().AllowUserSignup) { link += " / " + helper.ActionLink(SiteStrings.Navigation_Register, "Signup", "User").ToString(); } } return(MvcHtmlString.Create(prefix + link + suffix)); }
/// <summary> /// Provides a link to the filemanager page, with optional prefix and suffix tags or seperators. /// </summary> /// <returns>If the user is not logged in, an empty string is returned.</returns> public static MvcHtmlString FileManagerLink(this HtmlHelper helper, string prefix, string suffix) { ControllerBase controller = helper.ViewContext.Controller as ControllerBase; if (controller != null && (controller.Context.IsLoggedIn && (controller.Context.IsAdmin || controller.Context.IsEditor))) { string link = helper.ActionLink(SiteStrings.FileManager_Title, "Index", "FileManager").ToString(); return(MvcHtmlString.Create(prefix + link + suffix)); } else { return(MvcHtmlString.Empty); } }
/// <summary> /// Provides a link to the settings page, with optional prefix and suffix tags or seperators. /// </summary> /// <returns>If the user is not logged in and not an admin, an empty string is returned.</returns> public static MvcHtmlString SettingsLink(this HtmlHelper helper, string prefix, string suffix) { ControllerBase controller = helper.ViewContext.Controller as ControllerBase; if (controller != null && controller.Context.IsAdmin) { string link = helper.ActionLink(SiteStrings.Navigation_SiteSettings, "Index", "Settings").ToString(); return(MvcHtmlString.Create(prefix + link + suffix)); } else { return(MvcHtmlString.Empty); } }
public static MvcHtmlString LoginStatus(this HtmlHelper helper) { ControllerBase controller = helper.ViewContext.Controller as ControllerBase; if (controller != null && controller.Context.IsLoggedIn) { string text = string.Format("{0} {1}", SiteStrings.Shared_LoggedInAs, controller.Context.CurrentUsername); return(helper.ActionLink(text, "Profile", "User")); } else { return(MvcHtmlString.Create(SiteStrings.Shared_NotLoggedIn)); } }
/// <summary> /// Provides a link to the "new page" page, with optional prefix and suffix tags or seperators. /// </summary> /// <returns>If the user is not logged in and not an admin, an empty string is returned.</returns> public static MvcHtmlString NewPageLink(this HtmlHelper helper, string prefix, string suffix) { ControllerBase controller = helper.ViewContext.Controller as ControllerBase; if (controller != null && (controller.Context.IsLoggedIn && (controller.Context.IsAdmin || controller.Context.IsEditor))) { string link = helper.ActionLink(SiteStrings.Navigation_NewPage, "New", "Pages").ToString(); return(MvcHtmlString.Create(prefix + link + suffix)); } else { return(MvcHtmlString.Empty); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { Roadkill.Core.Mvc.Controllers.ControllerBase controller = filterContext.Controller as Roadkill.Core.Mvc.Controllers.ControllerBase; if (controller != null) { SiteSettings siteSettings = controller.SettingsService.GetSiteSettings(); if (siteSettings.IsRecaptchaEnabled) { string challengeValue = filterContext.HttpContext.Request.Form[CHALLENGE_KEY]; string responseValue = filterContext.HttpContext.Request.Form[RESPONSE_KEY]; RecaptchaValidator validator = new RecaptchaValidator(); validator.PrivateKey = siteSettings.RecaptchaPrivateKey; validator.RemoteIP = filterContext.HttpContext.Request.UserHostAddress; validator.Challenge = challengeValue; validator.Response = responseValue; RecaptchaResponse validationResponse = validator.Validate(); filterContext.ActionParameters["isCaptchaValid"] = validationResponse.IsValid; } } base.OnActionExecuting(filterContext); }