/// <summary> /// Gets information from the data source for a user based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user. /// </summary> /// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param> /// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param> /// <returns> /// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the specified user's information from the data source. /// </returns> public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) { var asGuid = providerUserKey.TryConvertTo <Guid>(); if (asGuid.Success) { var m = new Member(asGuid.Result); if (userIsOnline && LastLoginPropertyTypeAlias.IsNullOrWhiteSpace() == false) { UpdateMemberProperty(m, LastLoginPropertyTypeAlias, DateTime.Now); //don't raise events for this! It just sets the member dates, if we do raise events this will // cause all distributed cache to execute - which will clear out some caches we don't want. // http://issues.umbraco.org/issue/U4-3451 m.Save(false); } return(ConvertToMembershipUser(m)); } var asInt = providerUserKey.TryConvertTo <int>(); if (asInt.Success) { var m = new Member(asInt.Result); if (userIsOnline && LastLoginPropertyTypeAlias.IsNullOrWhiteSpace() == false) { UpdateMemberProperty(m, LastLoginPropertyTypeAlias, DateTime.Now); //don't raise events for this! It just sets the member dates, if we do raise events this will // cause all distributed cache to execute - which will clear out some caches we don't want. // http://issues.umbraco.org/issue/U4-3451 m.Save(false); } return(ConvertToMembershipUser(m)); } throw new InvalidOperationException("The " + GetType() + " provider only supports GUID or Int as a providerUserKey"); }
/// <summary> /// Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user. /// </summary> /// <param name="username">The name of the user to get information for.</param> /// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param> /// <returns> /// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the specified user's information from the data source. /// </returns> public override MembershipUser GetUser(string username, bool userIsOnline) { if (string.IsNullOrEmpty(username)) { return(null); } var m = Member.GetMemberFromLoginName(username); if (m == null) { return(null); } if (userIsOnline && LastLoginPropertyTypeAlias.IsNullOrWhiteSpace() == false) { UpdateMemberProperty(m, LastLoginPropertyTypeAlias, DateTime.Now); //don't raise events for this! It just sets the member dates, if we do raise events this will // cause all distributed cache to execute - which will clear out some caches we don't want. // http://issues.umbraco.org/issue/U4-3451 m.Save(false); } return(ConvertToMembershipUser(m)); }