mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
Merge
This commit is contained in:
@@ -7,7 +7,6 @@ using Orchard.Blogs.ViewModels;
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Mvc.AntiForgery;
|
using Orchard.Mvc.AntiForgery;
|
||||||
using Orchard.Mvc.FollowReturnUrl;
|
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
@@ -101,7 +100,7 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Edit"), FollowReturnUrl]
|
[HttpPost, ActionName("Edit")]
|
||||||
public ActionResult EditPOST(string blogSlug, int postId) {
|
public ActionResult EditPOST(string blogSlug, int postId) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
|
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using JetBrains.Annotations;
|
|||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Mvc.AntiForgery;
|
using Orchard.Mvc.AntiForgery;
|
||||||
using Orchard.Mvc.FollowReturnUrl;
|
|
||||||
using Orchard.Mvc.Results;
|
using Orchard.Mvc.Results;
|
||||||
using Orchard.Pages.Drivers;
|
using Orchard.Pages.Drivers;
|
||||||
using Orchard.Pages.Models;
|
using Orchard.Pages.Models;
|
||||||
@@ -174,7 +173,7 @@ namespace Orchard.Pages.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Edit"), FollowReturnUrl]
|
[HttpPost, ActionName("Edit")]
|
||||||
public ActionResult EditPOST(int id) {
|
public ActionResult EditPOST(int id) {
|
||||||
var page = _pageService.GetPageOrDraft(id);
|
var page = _pageService.GetPageOrDraft(id);
|
||||||
if (page == null)
|
if (page == null)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Security.Principal;
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Mvc.FollowReturnUrl;
|
using Orchard.Mvc.Extensions;
|
||||||
using Orchard.Mvc.ViewModels;
|
using Orchard.Mvc.ViewModels;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.Users.Services;
|
using Orchard.Users.Services;
|
||||||
@@ -52,7 +52,7 @@ namespace Orchard.Users.Controllers {
|
|||||||
return View("LogOn", new LogOnViewModel {Title = "Log On"});
|
return View("LogOn", new LogOnViewModel {Title = "Log On"});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, FollowReturnUrl]
|
[HttpPost]
|
||||||
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
|
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
|
||||||
Justification = "Needs to take same parameter type as Controller.Redirect()")]
|
Justification = "Needs to take same parameter type as Controller.Redirect()")]
|
||||||
public ActionResult LogOn(string userName, string password, bool rememberMe) {
|
public ActionResult LogOn(string userName, string password, bool rememberMe) {
|
||||||
@@ -63,14 +63,13 @@ namespace Orchard.Users.Controllers {
|
|||||||
|
|
||||||
_authenticationService.SignIn(user, rememberMe);
|
_authenticationService.SignIn(user, rememberMe);
|
||||||
|
|
||||||
return Redirect("~/");
|
return this.ReturnUrlRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
[FollowReturnUrl]
|
|
||||||
public ActionResult LogOff() {
|
public ActionResult LogOff() {
|
||||||
_authenticationService.SignOut();
|
_authenticationService.SignOut();
|
||||||
|
|
||||||
return Redirect("~/");
|
return this.ReturnUrlRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MinPasswordLength {
|
int MinPasswordLength {
|
||||||
|
|||||||
31
src/Orchard/Mvc/Extensions/ControllerExtensions.cs
Normal file
31
src/Orchard/Mvc/Extensions/ControllerExtensions.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
|
namespace Orchard.Mvc.Extensions {
|
||||||
|
public static class ControllerExtensions {
|
||||||
|
public static RedirectResult ReturnUrlRedirect(this Controller controller) {
|
||||||
|
var request = controller.HttpContext.Request;
|
||||||
|
Uri returnUrl = null;
|
||||||
|
try {
|
||||||
|
returnUrl = new Uri(request.QueryString["ReturnUrl"]);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
try {
|
||||||
|
returnUrl =
|
||||||
|
new Uri(string.Format("{0}://{1}{2}{3}", request.Url.Scheme, request.Url.Host,
|
||||||
|
request.Url.Port != 80 ? ":" + request.Url.Port : "",
|
||||||
|
request.QueryString["ReturnUrl"]));
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnUrl != null &&
|
||||||
|
returnUrl.Scheme == request.Url.Scheme &&
|
||||||
|
returnUrl.Port == request.Url.Port &&
|
||||||
|
returnUrl.Host == request.Url.Host) {
|
||||||
|
return new RedirectResult(returnUrl.ToString());
|
||||||
|
}
|
||||||
|
return new RedirectResult("~/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
|
|
||||||
namespace Orchard.Mvc.FollowReturnUrl {
|
|
||||||
[AttributeUsage(AttributeTargets.Method)]
|
|
||||||
public class FollowReturnUrlAttribute : FilterAttribute {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using Orchard.Mvc.Filters;
|
|
||||||
|
|
||||||
namespace Orchard.Mvc.FollowReturnUrl {
|
|
||||||
public class FollowReturnUrlFilter : FilterProvider, IActionFilter {
|
|
||||||
public void OnActionExecuting(ActionExecutingContext filterContext) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnActionExecuted(ActionExecutedContext filterContext) {
|
|
||||||
var attributes =
|
|
||||||
(FollowReturnUrlAttribute[])
|
|
||||||
filterContext.ActionDescriptor.GetCustomAttributes(typeof (FollowReturnUrlAttribute), false);
|
|
||||||
|
|
||||||
if (attributes.Length <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var request = filterContext.HttpContext.Request;
|
|
||||||
Uri returnUrl = null;
|
|
||||||
try {
|
|
||||||
returnUrl = new Uri(request.QueryString["ReturnUrl"]);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
try {
|
|
||||||
returnUrl =
|
|
||||||
new Uri(string.Format("{0}://{1}{2}{3}", request.Url.Scheme, request.Url.Host,
|
|
||||||
request.Url.Port != 80 ? ":" + request.Url.Port : "",
|
|
||||||
request.QueryString["ReturnUrl"]));
|
|
||||||
}
|
|
||||||
catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (returnUrl != null &&
|
|
||||||
returnUrl.Scheme == request.Url.Scheme &&
|
|
||||||
returnUrl.Port == request.Url.Port &&
|
|
||||||
returnUrl.Host == request.Url.Host) {
|
|
||||||
filterContext.Result = new RedirectResult(returnUrl.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -156,10 +156,9 @@
|
|||||||
<Compile Include="Extensions\StringExtensions.cs" />
|
<Compile Include="Extensions\StringExtensions.cs" />
|
||||||
<Compile Include="Extensions\UriExtensions.cs" />
|
<Compile Include="Extensions\UriExtensions.cs" />
|
||||||
<Compile Include="Mvc\AntiForgery\ValidateAntiForgeryTokenOrchardAttribute.cs" />
|
<Compile Include="Mvc\AntiForgery\ValidateAntiForgeryTokenOrchardAttribute.cs" />
|
||||||
<Compile Include="Mvc\FollowReturnUrl\FollowReturnUrlFilter.cs" />
|
<Compile Include="Mvc\Extensions\ControllerExtensions.cs" />
|
||||||
<Compile Include="Mvc\Html\FileRegistrationContextExtensions.cs" />
|
<Compile Include="Mvc\Html\FileRegistrationContextExtensions.cs" />
|
||||||
<Compile Include="Mvc\Extensions\UrlHelperExtensions.cs" />
|
<Compile Include="Mvc\Extensions\UrlHelperExtensions.cs" />
|
||||||
<Compile Include="Mvc\FollowReturnUrl\FollowReturnUrlAttribute.cs" />
|
|
||||||
<Compile Include="Mvc\ViewModels\AdaptedViewModel.cs" />
|
<Compile Include="Mvc\ViewModels\AdaptedViewModel.cs" />
|
||||||
<Compile Include="Mvc\ViewUserControl.cs">
|
<Compile Include="Mvc\ViewUserControl.cs">
|
||||||
<SubType>ASPXCodeBehind</SubType>
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
|
|||||||
Reference in New Issue
Block a user