Merge commit '85a74e4fa700c83bab4bf3436f69f045029932cd' into 7.1.0

Conflicts:
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Web/Controllers/UmbLoginController.cs
	src/Umbraco.Web/Controllers/UmbLoginStatusController.cs
	src/Umbraco.Web/Controllers/UmbProfileController.cs
	src/Umbraco.Web/Controllers/UmbRegisterController.cs
This commit is contained in:
Shannon
2014-03-13 14:12:02 +11:00
9 changed files with 138 additions and 43 deletions

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Rdbms;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
{
[Migration("6.2.0", 2, GlobalSettings.UmbracoMigrationName)]
public class UpdateToNewMemberPropertyAliases : MigrationBase
{
public override void Up()
{
Execute.Code(Update);
}
internal static string Update(Database database)
{
if (database != null)
{
var aliasMap = new Dictionary<string, string>
{
{"umbracoPasswordRetrievalQuestionPropertyTypeAlias", Constants.Conventions.Member.PasswordQuestion},
{"umbracoPasswordRetrievalAnswerPropertyTypeAlias", Constants.Conventions.Member.PasswordAnswer},
{"umbracoCommentPropertyTypeAlias", Constants.Conventions.Member.Comments},
{"umbracoApprovePropertyTypeAlias", Constants.Conventions.Member.IsApproved},
{"umbracoLockPropertyTypeAlias", Constants.Conventions.Member.IsLockedOut},
{"umbracoLastLoginPropertyTypeAlias", Constants.Conventions.Member.LastLoginDate},
{"umbracoMemberLastPasswordChange", Constants.Conventions.Member.LastPasswordChangeDate},
{"umbracoMemberLastLockout", Constants.Conventions.Member.LastLockoutDate},
{"umbracoFailedPasswordAttemptsPropertyTypeAlias", Constants.Conventions.Member.FailedPasswordAttempts}
};
const string propertyTypeUpdateSql = @"UPDATE cmsPropertyType
SET Alias = @newAlias
WHERE Alias = @oldAlias AND contentTypeId IN (
SELECT DISTINCT cmsContentType.nodeId FROM cmsPropertyType
INNER JOIN cmsContentType ON cmsPropertyType.contentTypeId = cmsContentType.nodeId
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
WHERE umbracoNode.nodeObjectType = @objectType)";
const string xmlSelectSql = @"SELECT cmsContentXml.* FROM cmsContentXml
INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id
WHERE umbracoNode.nodeObjectType = @objectType";
using (var trans = database.GetTransaction())
{
try
{
//Upate all of the property type aliases
foreach (var map in aliasMap)
{
database.Execute(propertyTypeUpdateSql, new { newAlias = map.Value, oldAlias = map.Key, objectType = Constants.ObjectTypes.MemberType });
}
//Update all of the XML
var items = database.Fetch<ContentXmlDto>(xmlSelectSql, new { objectType = Constants.ObjectTypes.Member });
foreach (var item in items)
{
foreach (var map in aliasMap)
{
item.Xml = item.Xml.Replace("<" + map.Key + ">", "<" + map.Value + ">");
item.Xml = item.Xml.Replace("</" + map.Key + ">", "</" + map.Value + ">");
}
database.Update(item);
}
trans.Complete();
}
catch (Exception ex)
{
LogHelper.Error<UpdateToNewMemberPropertyAliases>("Exception was thrown when trying to upgrade old member aliases to the new ones", ex);
throw;
}
}
}
return string.Empty;
}
public override void Down()
{
throw new NotImplementedException();
}
}
}

View File

@@ -358,6 +358,7 @@
<Compile Include="Persistence\Factories\MemberGroupFactory.cs" />
<Compile Include="Persistence\Mappers\MemberGroupMapper.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenOne\UpdateToNewMemberPropertyAliases.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\UpdateToNewMemberPropertyAliases.cs" />
<Compile Include="Persistence\SqlExtensions.cs" />
<Compile Include="PropertyEditors\DefaultPropertyValueConverterAttribute.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSeven\UpdateRelatedLinksData.cs" />

View File

@@ -32,9 +32,9 @@ namespace Umbraco.Web.Controllers
}
//redirect to current page by default
TempData.Add("LoginSuccess", true);
//return RedirectToCurrentUmbracoPage();
return RedirectToCurrentUmbracoUrl();
TempData["LoginSuccess"] = true;
return RedirectToCurrentUmbracoPage();
//return RedirectToCurrentUmbracoUrl();
}
}
}

View File

@@ -30,7 +30,7 @@ namespace Umbraco.Web.Controllers
}
//redirect to current page by default
TempData.Add("LogoutSuccess", true);
TempData["LogoutSuccess"] = true;
return RedirectToCurrentUmbracoPage();
}
}

View File

@@ -41,7 +41,7 @@ namespace Umbraco.Web.Controllers
}
//redirect to current page by default
TempData.Add("ProfileUpdateSuccess", true);
TempData["ProfileUpdateSuccess"] = true;
return RedirectToCurrentUmbracoPage();
}
}

View File

@@ -33,7 +33,7 @@ namespace Umbraco.Web.Controllers
return Redirect(model.RedirectUrl);
}
//redirect to current page by default
TempData.Add("FormSuccess", true);
TempData["FormSuccess"] = true;
return RedirectToCurrentUmbracoPage();
case MembershipCreateStatus.InvalidUserName:
ModelState.AddModelError((model.UsernameIsEmail || model.Username == null)

View File

@@ -8,43 +8,6 @@ using Umbraco.Web.Routing;
namespace Umbraco.Web.Mvc
{
/// <summary>
/// Redirects to the current URL rendering an Umbraco page
/// </summary>
/// <remarks>
/// this is useful if you need to redirect
/// to the current page but the current page is actually a rewritten URL normally done with something like
/// Server.Transfer.
/// </remarks>
public class RedirectToUmbracoUrlResult : ActionResult
{
private readonly UmbracoContext _umbracoContext;
/// <summary>
/// Creates a new RedirectToUmbracoResult
/// </summary>
/// <param name="umbracoContext"></param>
public RedirectToUmbracoUrlResult(UmbracoContext umbracoContext)
{
_umbracoContext = umbracoContext;
}
public override void ExecuteResult(ControllerContext context)
{
if (context == null) throw new ArgumentNullException("context");
if (context.IsChildAction)
{
throw new InvalidOperationException("Cannot redirect from a Child Action");
}
var destinationUrl = _umbracoContext.OriginalRequestUrl.PathAndQuery;
context.Controller.TempData.Keep();
context.HttpContext.Response.Redirect(destinationUrl, endResponse: false);
}
}
/// <summary>
/// Redirects to an Umbraco page by Id or Entity
/// </summary>
public class RedirectToUmbracoPageResult : ActionResult

View File

@@ -0,0 +1,42 @@
using System;
using System.Web.Mvc;
namespace Umbraco.Web.Mvc
{
/// <summary>
/// Redirects to the current URL rendering an Umbraco page
/// </summary>
/// <remarks>
/// this is useful if you need to redirect
/// to the current page but the current page is actually a rewritten URL normally done with something like
/// Server.Transfer.
/// </remarks>
public class RedirectToUmbracoUrlResult : ActionResult
{
private readonly UmbracoContext _umbracoContext;
/// <summary>
/// Creates a new RedirectToUmbracoResult
/// </summary>
/// <param name="umbracoContext"></param>
public RedirectToUmbracoUrlResult(UmbracoContext umbracoContext)
{
_umbracoContext = umbracoContext;
}
public override void ExecuteResult(ControllerContext context)
{
if (context == null) throw new ArgumentNullException("context");
if (context.IsChildAction)
{
throw new InvalidOperationException("Cannot redirect from a Child Action");
}
var destinationUrl = _umbracoContext.OriginalRequestUrl.PathAndQuery;
context.Controller.TempData.Keep();
context.HttpContext.Response.Redirect(destinationUrl, endResponse: false);
}
}
}

View File

@@ -342,6 +342,7 @@
<Compile Include="Models\ImageCropData.cs" />
<Compile Include="Models\IRenderModel.cs" />
<Compile Include="Models\PostRedirectModel.cs" />
<Compile Include="Mvc\RedirectToUmbracoUrlResult.cs" />
<Compile Include="PublishedCache\MemberPublishedContent.cs" />
<Compile Include="PublishedCache\RawValueProperty.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\PublishedFragment.cs" />