mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#18425: Fixing challenge email again
Work Item: 18425 --HG-- branch : 1.x
This commit is contained in:
@@ -150,9 +150,7 @@ namespace Orchard.Users.Controllers {
|
|||||||
siteUrl = HttpContext.Request.ToRootUrlString();
|
siteUrl = HttpContext.Request.ToRootUrlString();
|
||||||
}
|
}
|
||||||
|
|
||||||
siteUrl = siteUrl.TrimEnd('/');
|
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.MakeAbsolute(Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce}), siteUrl));
|
||||||
|
|
||||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => siteUrl + "/" + Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce}).TrimStart('/') );
|
|
||||||
|
|
||||||
foreach (var userEventHandler in _userEventHandlers) {
|
foreach (var userEventHandler in _userEventHandlers) {
|
||||||
userEventHandler.SentChallengeEmail(user);
|
userEventHandler.SentChallengeEmail(user);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Orchard.Mvc.Extensions;
|
|||||||
using System;
|
using System;
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
using Orchard.UI.Navigation;
|
using Orchard.UI.Navigation;
|
||||||
|
using Orchard.Utility.Extensions;
|
||||||
|
|
||||||
namespace Orchard.Users.Controllers {
|
namespace Orchard.Users.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
@@ -297,7 +298,12 @@ namespace Orchard.Users.Controllers {
|
|||||||
var user = Services.ContentManager.Get<IUser>(id);
|
var user = Services.ContentManager.Get<IUser>(id);
|
||||||
|
|
||||||
if ( user != null ) {
|
if ( user != null ) {
|
||||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.AbsoluteAction(() => Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce})));
|
var siteUrl = Services.WorkContext.CurrentSite.As<SiteSettings2Part>().BaseUrl;
|
||||||
|
if (String.IsNullOrWhiteSpace(siteUrl)) {
|
||||||
|
siteUrl = HttpContext.Request.ToRootUrlString();
|
||||||
|
}
|
||||||
|
|
||||||
|
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.MakeAbsolute(Url.Action("ChallengeEmail", "Account", new { Area = "Orchard.Users", nonce = nonce }), siteUrl));
|
||||||
Services.Notifier.Information(T("Challenge email sent to {0}", user.UserName));
|
Services.Notifier.Information(T("Challenge email sent to {0}", user.UserName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,27 @@ namespace Orchard.Mvc.Extensions {
|
|||||||
return urlHelper.MakeAbsolute(urlHelper.Action(actionName, controller, routeValues));
|
return urlHelper.MakeAbsolute(urlHelper.Action(actionName, controller, routeValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MakeAbsolute(this UrlHelper urlHelper, string url) {
|
public static string MakeAbsolute(this UrlHelper urlHelper, string url, string baseUrl = null) {
|
||||||
var siteUrl = urlHelper.RequestContext.HttpContext.Request.ToRootUrlString();
|
if(String.IsNullOrEmpty(baseUrl)) {
|
||||||
return siteUrl + url;
|
baseUrl = urlHelper.RequestContext.HttpContext.Request.ToRootUrlString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove any application path from the base url
|
||||||
|
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
||||||
|
|
||||||
|
// orchardlocal/foo/bar => /orchardlocal/foo/bar
|
||||||
|
if(!url.StartsWith("/")) {
|
||||||
|
url = "/" + url;
|
||||||
|
}
|
||||||
|
// /orchardlocal/foo/bar => foo/bar
|
||||||
|
if (url.StartsWith(applicationPath)) {
|
||||||
|
url = url.Substring(applicationPath.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
baseUrl = baseUrl.TrimEnd('/');
|
||||||
|
url = url.TrimStart('/');
|
||||||
|
|
||||||
|
return baseUrl + "/" + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user