mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-23 13:22:08 +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 = siteUrl.TrimEnd('/');
|
||||
|
||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => siteUrl + "/" + Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce}).TrimStart('/') );
|
||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.MakeAbsolute(Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce}), siteUrl));
|
||||
|
||||
foreach (var userEventHandler in _userEventHandlers) {
|
||||
userEventHandler.SentChallengeEmail(user);
|
||||
|
||||
@@ -18,6 +18,7 @@ using Orchard.Mvc.Extensions;
|
||||
using System;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Users.Controllers {
|
||||
[ValidateInput(false)]
|
||||
@@ -297,7 +298,12 @@ namespace Orchard.Users.Controllers {
|
||||
var user = Services.ContentManager.Get<IUser>(id);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,27 @@ namespace Orchard.Mvc.Extensions {
|
||||
return urlHelper.MakeAbsolute(urlHelper.Action(actionName, controller, routeValues));
|
||||
}
|
||||
|
||||
public static string MakeAbsolute(this UrlHelper urlHelper, string url) {
|
||||
var siteUrl = urlHelper.RequestContext.HttpContext.Request.ToRootUrlString();
|
||||
return siteUrl + url;
|
||||
public static string MakeAbsolute(this UrlHelper urlHelper, string url, string baseUrl = null) {
|
||||
if(String.IsNullOrEmpty(baseUrl)) {
|
||||
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