diff --git a/src/Umbraco.Web.UI/config/metablogConfig.config b/src/Umbraco.Web.UI/config/metablogConfig.config
index adf71d17d0..83cc2c1aa1 100644
--- a/src/Umbraco.Web.UI/config/metablogConfig.config
+++ b/src/Umbraco.Web.UI/config/metablogConfig.config
@@ -5,7 +5,7 @@
0
1080
False
- Base
+ Home
diff --git a/src/Umbraco.Web/Cache/CacheRefresherClient.cs b/src/Umbraco.Web/Cache/CacheRefresherClient.cs
deleted file mode 100644
index 2943c8579c..0000000000
--- a/src/Umbraco.Web/Cache/CacheRefresherClient.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-//using Umbraco.Core.IO;
-
-//namespace Umbraco.Web.Cache
-//{
-
-// ///
-// /// The client Soap service for making distrubuted cache calls between servers
-// ///
-// [System.Diagnostics.DebuggerStepThroughAttribute()]
-// [System.ComponentModel.DesignerCategoryAttribute("code")]
-// [System.Web.Services.WebServiceBindingAttribute(Name = "CacheRefresherSoap", Namespace = "http://umbraco.org/webservices/")]
-// internal class CacheRefresherClient : System.Web.Services.Protocols.SoapHttpClientProtocol
-// {
-
-// ///
-// public CacheRefresherClient()
-// {
-// // only set the url if the httpcontext is present, else it's set by the cache dispatcher methods (when using distributed calls)
-// if (System.Web.HttpContext.Current != null)
-// this.Url = "http://" + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/cacheRefresher.asmx";
-
-// }
-
-// ///
-// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RefreshAll", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
-// public void RefreshAll(System.Guid uniqueIdentifier, string Login, string Password)
-// {
-// this.Invoke("RefreshAll", new object[] {
-// uniqueIdentifier,
-// Login,
-// Password});
-// }
-
-// ///
-// public System.IAsyncResult BeginRefreshAll(System.Guid uniqueIdentifier, string Login, string Password, System.AsyncCallback callback, object asyncState)
-// {
-// return this.BeginInvoke("RefreshAll", new object[] {
-// uniqueIdentifier,
-// Login,
-// Password}, callback, asyncState);
-// }
-
-// ///
-// public void EndRefreshAll(System.IAsyncResult asyncResult)
-// {
-// this.EndInvoke(asyncResult);
-// }
-
-// ///
-// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RefreshByGuid", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
-// public void RefreshByGuid(System.Guid uniqueIdentifier, System.Guid Id, string Login, string Password)
-// {
-// this.Invoke("RefreshByGuid", new object[] {
-// uniqueIdentifier,
-// Id,
-// Login,
-// Password});
-// }
-
-// ///
-// public System.IAsyncResult BeginRefreshByGuid(System.Guid uniqueIdentifier, System.Guid Id, string Login, string Password, System.AsyncCallback callback, object asyncState)
-// {
-// return this.BeginInvoke("RefreshByGuid", new object[] {
-// uniqueIdentifier,
-// Id,
-// Login,
-// Password}, callback, asyncState);
-// }
-
-// ///
-// public void EndRefreshByGuid(System.IAsyncResult asyncResult)
-// {
-// this.EndInvoke(asyncResult);
-// }
-
-// ///
-// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RefreshById", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
-// public void RefreshById(System.Guid uniqueIdentifier, int Id, string Login, string Password)
-// {
-// this.Invoke("RefreshById", new object[] {
-// uniqueIdentifier,
-// Id,
-// Login,
-// Password});
-// }
-
-// ///
-// public System.IAsyncResult BeginRefreshById(System.Guid uniqueIdentifier, int Id, string Login, string Password, System.AsyncCallback callback, object asyncState)
-// {
-// return this.BeginInvoke("RefreshById", new object[] {
-// uniqueIdentifier,
-// Id,
-// Login,
-// Password}, callback, asyncState);
-// }
-
-// ///
-// public void EndRefreshById(System.IAsyncResult asyncResult)
-// {
-// this.EndInvoke(asyncResult);
-// }
-
-// ///
-// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RemoveById", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
-// public void RemoveById(System.Guid uniqueIdentifier, int Id, string Login, string Password)
-// {
-// this.Invoke("RemoveById", new object[] {
-// uniqueIdentifier,
-// Id,
-// Login,
-// Password});
-// }
-
-// ///
-// public System.IAsyncResult BeginRemoveById(System.Guid uniqueIdentifier, int Id, string Login, string Password, System.AsyncCallback callback, object asyncState)
-// {
-// return this.BeginInvoke("RemoveById", new object[] {
-// uniqueIdentifier,
-// Id,
-// Login,
-// Password}, callback, asyncState);
-// }
-
-// ///
-// public void EndRemoveById(System.IAsyncResult asyncResult)
-// {
-// this.EndInvoke(asyncResult);
-// }
-
-// ///
-// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/GetRefreshers", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
-// public System.Xml.XmlNode GetRefreshers(string Login, string Password)
-// {
-// object[] results = this.Invoke("GetRefreshers", new object[] {
-// Login,
-// Password});
-// return ((System.Xml.XmlNode)(results[0]));
-// }
-
-// ///
-// public System.IAsyncResult BeginGetRefreshers(string Login, string Password, System.AsyncCallback callback, object asyncState)
-// {
-// return this.BeginInvoke("GetRefreshers", new object[] {
-// Login,
-// Password}, callback, asyncState);
-// }
-
-// ///
-// public System.Xml.XmlNode EndGetRefreshers(System.IAsyncResult asyncResult)
-// {
-// object[] results = this.EndInvoke(asyncResult);
-// return ((System.Xml.XmlNode)(results[0]));
-// }
-// }
-//}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs b/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
index f5f4d35b14..29424ae93b 100644
--- a/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
+++ b/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
@@ -1,6 +1,7 @@
using Umbraco.Core;
using Umbraco.Core.Services;
using umbraco;
+using umbraco.BusinessLogic;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.macro;
using umbraco.cms.businesslogic.member;
@@ -18,6 +19,11 @@ namespace Umbraco.Web.Cache
{
if (UmbracoSettings.UmbracoLibraryCacheDuration <= 0) return;
+ //Bind to user events
+
+ User.Saving += UserSaving;
+ User.Deleting += UserDeleting;
+
//Bind to template events
Template.AfterSave += TemplateAfterSave;
@@ -44,6 +50,16 @@ namespace Umbraco.Web.Cache
MediaService.Trashing += MediaServiceTrashing;
}
+ static void UserDeleting(User sender, System.EventArgs e)
+ {
+ DistributedCache.Instance.RemoveUserCache(sender.Id);
+ }
+
+ static void UserSaving(User sender, System.EventArgs e)
+ {
+ DistributedCache.Instance.RefreshUserCache(sender.Id);
+ }
+
///
/// Removes cache for template
///
diff --git a/src/Umbraco.Web/Cache/DistributedCache.cs b/src/Umbraco.Web/Cache/DistributedCache.cs
index a02f3bb637..2d6989fcf3 100644
--- a/src/Umbraco.Web/Cache/DistributedCache.cs
+++ b/src/Umbraco.Web/Cache/DistributedCache.cs
@@ -34,6 +34,7 @@ namespace Umbraco.Web.Cache
public const string MemberCacheRefresherId = "E285DF34-ACDC-4226-AE32-C0CB5CF388DA";
public const string MediaCacheRefresherId = "B29286DD-2D40-4DDB-B325-681226589FEC";
public const string MacroCacheRefresherId = "7B1E683C-5F34-43dd-803D-9699EA1E98CA";
+ public const string UserCacheRefresherId = "E057AF6D-2EE6-41F4-8045-3694010F0AA6";
#endregion
diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
index 7b6f1c8dae..1e2d64c007 100644
--- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
+++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
@@ -7,6 +7,16 @@ namespace Umbraco.Web.Cache
///
public static class DistributedCacheExtensions
{
+ public static void RemoveUserCache(this DistributedCache dc, int userId)
+ {
+ dc.Remove(new Guid(DistributedCache.UserCacheRefresherId), userId);
+ }
+
+ public static void RefreshUserCache(this DistributedCache dc, int userId)
+ {
+ dc.Refresh(new Guid(DistributedCache.UserCacheRefresherId), userId);
+ }
+
///
/// Refreshes the cache amongst servers for a template
///
diff --git a/src/Umbraco.Web/Cache/UserCacheRefresher.cs b/src/Umbraco.Web/Cache/UserCacheRefresher.cs
new file mode 100644
index 0000000000..112024195e
--- /dev/null
+++ b/src/Umbraco.Web/Cache/UserCacheRefresher.cs
@@ -0,0 +1,41 @@
+using System;
+using Umbraco.Core;
+using umbraco.interfaces;
+
+namespace Umbraco.Web.Cache
+{
+ ///
+ /// Handles User cache invalidation/refreshing
+ ///
+ public class UserCacheRefresher : ICacheRefresher
+ {
+ public Guid UniqueIdentifier
+ {
+ get { return Guid.Parse(DistributedCache.UserCacheRefresherId); }
+ }
+ public string Name
+ {
+ get { return "User cache refresher"; }
+ }
+
+ public void RefreshAll()
+ {
+ ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch("UmbracoUser");
+ }
+
+ public void Refresh(int id)
+ {
+ Remove(id);
+ }
+
+ public void Remove(int id)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearCacheItem(string.Format("UmbracoUser{0}", id.ToString()));
+ }
+
+ public void Refresh(Guid id)
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 2a468b0059..8004f1e490 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -244,7 +244,6 @@
-
@@ -253,6 +252,7 @@
+
diff --git a/src/umbraco.businesslogic/User.cs b/src/umbraco.businesslogic/User.cs
index 3320e4fd9c..0f1e5d4946 100644
--- a/src/umbraco.businesslogic/User.cs
+++ b/src/umbraco.businesslogic/User.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using Umbraco.Core;
using Umbraco.Core.Logging;
using umbraco.DataLayer;
using System.Collections.Generic;
@@ -645,7 +646,7 @@ namespace umbraco.BusinessLogic
{
this.LoginName = DateTime.Now.ToString("yyyyMMdd") + "_" + this.LoginName;
}
-
+ this.Save();
}
///
@@ -890,12 +891,11 @@ namespace umbraco.BusinessLogic
///
/// Flushes the user from cache.
///
+ [Obsolete("This method should not be used, cache flushing is handled automatically by event handling in the web application and ensures that all servers are notified, this will not notify all servers in a load balanced environment")]
public void FlushFromCache()
{
OnFlushingFromCache(EventArgs.Empty);
-
- if (System.Web.HttpRuntime.Cache[string.Format("UmbracoUser{0}", Id.ToString())] != null)
- System.Web.HttpRuntime.Cache.Remove(string.Format("UmbracoUser{0}", Id.ToString()));
+ ApplicationContext.Current.ApplicationCache.ClearCacheItem(string.Format("UmbracoUser{0}", Id.ToString()));
}
///
@@ -905,22 +905,19 @@ namespace umbraco.BusinessLogic
///
public static User GetUser(int id)
{
- if (System.Web.HttpRuntime.Cache[string.Format("UmbracoUser{0}", id.ToString())] == null)
- {
-
- try
- {
- User u = new User(id);
- System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoUser{0}", id.ToString()), u);
- }
- catch (ArgumentException)
- {
- //no user was found
- return null;
- }
-
- }
- return (User)System.Web.HttpRuntime.Cache[string.Format("UmbracoUser{0}", id.ToString())];
+ return ApplicationContext.Current.ApplicationCache.GetCacheItem(
+ string.Format("UmbracoUser{0}", id.ToString()), () =>
+ {
+ try
+ {
+ return new User(id);
+ }
+ catch (ArgumentException)
+ {
+ //no user was found
+ return null;
+ }
+ });
}
diff --git a/src/umbraco.providers/UsersMembershipProvider.cs b/src/umbraco.providers/UsersMembershipProvider.cs
index e0216d0ccb..e90d7b2495 100644
--- a/src/umbraco.providers/UsersMembershipProvider.cs
+++ b/src/umbraco.providers/UsersMembershipProvider.cs
@@ -248,6 +248,7 @@ namespace umbraco.providers
User user = new User(username);
string encodedPassword = EncodePassword(newPassword);
user.Password = encodedPassword;
+ user.Save();
return (user.ValidatePassword(encodedPassword)) ? true : false;
}
@@ -525,6 +526,7 @@ namespace umbraco.providers
{
User user = new User(userName);
user.Disabled = false;
+ user.Save();
}
catch (Exception)
{