jerrynott
  •  jerrynott
  • 53.6% (Neutral)
  • YAF Forumling Topic Starter
2010-08-25T23:55:41Z
Hi

I have an existing application and have added a YAF forum to it. The YAF forum uses the existing Memembership provider and that's all good.

However when a new yaf user is added to the yaf database tables in the RoleMembershipProvider.UpdateForumUser() function the stored proc [yaf_user_aspnet] is used to add or edit the user to the [yaf_User] table.

In my existing membership we use email as [username] and as 📧. And so in the UpdateForumUser() function I have converted the email to a username (by using the bit before the @ only). This can now lead to duplicate names - ie 'jerry@gmail.com' and 'jerry@yahoo.com' both have [Name] = 'jerry'.
I have changed the stored proc [yaf_user_aspnet] so that it only matches and updates if the [ProviderUserKey] matches.

My question is: Does it matter if there is more than one [yaf_User] entry (database row) with the same [Name] - even if they always have different [ProviderUserKey] 's .


Thanks for any help.
Sponsor
bbobb
  •  bbobb
  • 100% (Exalted)
  • YAF Developer
2010-08-26T04:50:37Z
No one can say for sure. I can only guess that it doesn't matter, but it could be much better for them to be unique to avoid hardly detectable problems. You can simply create a test db and simulate the situation for 2 users. You didn't specify YAF version, but 1.9.4 has Display Name feature which can be enabled.
jerrynott
  •  jerrynott
  • 53.6% (Neutral)
  • YAF Forumling Topic Starter
2010-08-26T05:31:18Z
Thanks for the reply.
I have tried it and there is a unique key costraint on the [name] field...
So I've just created a custom bit of code that tries to create / edit the user in the RoleMembershipHelper.cs

Note: I've changed the SP [yaf_user_aspnet] to only match on [ProviderUserKey]

public static void UpdateForumUser( MembershipUser user, int pageBoardID )
{
if ( user == null ) // Check to make sure its not a guest
{
return;
}

// Get the emai stub (so email is not used as forum username) - jerry
string emailStub = user.Email;
int indexAT = emailStub.IndexOf("@");
if (indexAT > 1)
{
emailStub = emailStub.Substring(0, indexAT);
}

// Now try adding the user until a valid username is found (add index to stub until it is)
// NOTE: This is done to distinguish between jerry@unimail.com and jerry@gmail.com
int nUserID = 0;
int index = 0;
string userName = emailStub;
while (index < 10 && nUserID == 0)
{
nUserID = DB.user_aspnet(pageBoardID, userName, user.Email, user.ProviderUserKey, user.IsApproved);
index++;
userName = emailStub + index.ToString();
}



This seems to work so far!!
Thanks
jerrynott
  •  jerrynott
  • 53.6% (Neutral)
  • YAF Forumling Topic Starter
2010-08-26T06:16:54Z
Having tested this a bit more there is an issue with this - mainly because of the YAFUserProfile.cs that creates a profile from a username..

public static YafUserProfile GetProfile(string userName)
{
return Create(userName) as YafUserProfile;
}

Basically my issue of masking the email addresses is causing me some grief!! The problem being the existing (and unchangeable) Membership provider that is in place uses the actual email as the email and username. I am begining to think that this means that the replicated users in the yaf table [yaf_user] table should follow a similar pattern.

I am using YAF 1.9.4 RC1

I think I need to look at Display Name feature. I've had a look but any pointers would be good.
bbobb
  •  bbobb
  • 100% (Exalted)
  • YAF Developer
2010-08-26T06:40:39Z
jerrynott wrote:


I am using YAF 1.9.4 RC1


Display Name feature appeared later, somewhere about RC2. You should use final for it.

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved